Question: Top Talkative Users
Given a log file, find the top N most talkative users.
10:00 <john> hi!
10:01 <maria> hello!
10:07 <john> can you link the design?
// Returns e.g.
// [
// {username: "john", wordCount: 1},
// {username: "maria", wordCount: 1},
// {username: "john", wordCount: 5}
// ]
public List<UserWordCount> parseLog(String filepath) {// Implemented for you}
给定一个聊天日志文件,每行格式为:
< 时间 > <username> <message>
需要统计每个用户发送的 总词数(word count),然后返回 最健谈的前 N 个用户 。
核心任务:
- 对日志逐行解析,提取 username
- 分割 message 计算词数
- 用哈希表统计 word count
- 根据词数降序排序,取前 N
VOprep 团队长期陪同学员实战各类大厂 OA 与 VO,包括 OpenAI、Google、Amazon、Citadel、SIG 等,提供实时答案助攻、远程陪练与面试节奏提醒,帮助大家在关键时刻不卡壳。
如果你也在准备 Stripe 或类似工程向公司,可以了解一下我们的定制助攻方案——从编程面到系统设计,全程护航上岸。
正文完