Code Room
CodingMediumcod-g1253
Subject HashingLevel Entry–Mid~15 minCommon in Algorithms & data structures interviewsIndustries Software development

Question

A streaming service logs each play as a single string "artist:song" — the artist name, a colon, then the song title (neither part contains a colon, both are non-empty). The same song can be played many times. From a list of such entries, compute for each artist how many distinct songs of theirs were played, and return a dictionary mapping artist to that distinct-song count. For example, ["ada:one", "ada:two", "bea:one", "ada:one"] returns {"ada": 2, "bea": 1} — note the repeated "ada:one" does not raise ada’s count.

Implement
songs_per_artist(plays: list[str]) → dict[str,int]
Examples
in[["ada:one","ada:two","bea:one","ada:one"]]out{"ada":2,"bea":1}
What a strong answer looks like

State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.

Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.

Run or narrate your approach, then ask the coach.