First unique play

Write codeEasy10 min

Your task

A music app keeps a play log for one listening session: a list of song ids in the order they were played. The product team wants to surface the first song the listener played exactly once across the whole session. Given the log, return the id of the earliest-played song whose total play count is 1. If every song in the log was played more than once, or the log is empty, return an empty string. For example, in ["hills","echo","hills","nova"] the answer is "echo".

Examples

first_unique_song(plays: list[str]) -> str
Example 1
Inputfirst_unique_song(["hills", "echo", "hills", "nova"])
Output"echo"