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

  1. Example 1

    Input: pairs = ["ann-bo","bo-cy","ann-cy","bo-dee","bo-eli"]

    Output: ["bo","ann","cy","dee","eli"]

    Explanation: bo is in 4 pairs, ann and cy in 2 each, and dee and eli in 1 each. Ties are ordered by name, so the result is bo, 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.
Import a question

Code

Loading editor…

Ln 1, Col 1

Start an attempt to use Coach.