First play index

Write codeEasy10 min

Your task

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.

Examples

first_play_index(plays: list[str]) -> dict[str,int]
Example 1
Inputfirst_play_index(["a", "b", "a", "c"])
Output{"a": 0, "b": 1, "c": 3}