Most Active Users
Asked at Google
Reported by the problem's creator, not verified
A messaging service logs who talked to whom. Each log entry is a string of two user names joined by one hyphen, such as "ann-bo". Names are non-empty, case-sensitive, and contain only letters and digits.
Implement top_users(pairs) where pairs is the list of log entries.
Examples
Example 1
Input: pairs =
["ann-bo","bo-cy","ann-cy","bo-dee","bo-eli"]Output:
["bo","ann","cy","dee","eli"]Explanation:
bois in 4 pairs,annandcyin 2 each, anddeeandeliin 1 each. Ties are ordered by name, so the result isbo,ann,cy,dee,eli.
Import your own questions
Paste a question you were asked and get a full problem: statement, tests and a checked solution.