Code RoomDistinct songs per artist
MediumPrep Room Coding #435

Distinct songs per artist

CodingAlgorithms & data structuresEntry–Mid~15 min

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.

0:00 of about 15 min
InputExpectedGot
[["ada:one","ada:two","bea:one","ada:one"]]{"ada":2,"bea":1}not run yetsample