Question
A listening-history service wants a quick lookup of when each song first appeared in a session. Given the session play log — a list of song ids in play order — return a dictionary that maps every distinct song id to the zero-based index of its first play. Later plays never change the stored index. For example, ["a", "b", "a", "c"] returns {"a": 0, "b": 1, "c": 3}: the second "a" at index 2 is ignored because "a" was first played at index 0.
first_play_index(plays: list[str]) → dict[str,int][["a","b","a","c"]]out{"a":0,"b":1,"c":3}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.