Chat Top Talkers

Asked at Google· Screen

Reported by the problem's creator, not verified

Import another question

A chat room transcript is a list of text lines. A message line has the form HH:MM <name> text: two digits, a colon, two digits, a space, the sender's name in angle brackets, and then either nothing or a space followed by the message text. Names use letters, digits and _, and are case-sensitive. Any other line (a join notice, a blank line, a malformed line) is not a message and is ignored. A message's word count is the number of whitespace-separated words in its text, so an empty text counts 0 words.

Examples

  1. Example 1

    Input: log = ["10:00 <alice> Hi! What's up?","10:01 <bob> Hey","10:02 * carol joined the room","10:03 <alice> Dinner tonight?","10:04 <carol> I'm down, but only if it isn't vegan","10:05 <bob> Fine by me"], n = 2

    Output: [["carol",8],["alice",5]]

    Explanation: alice wrote 3 + 2 = 5 words, bob 1 + 3 = 4, and carol 8. The join notice is not a message and adds nothing, so the top two are carol (8) then alice (5).

Import your own questions
Paste a question you were asked and get a full problem: statement, tests and a checked solution.
Import a question

Code

Loading editor…

Ln 1, Col 1

Start an attempt to use Coach.