Shared distinct tags
Two curators each maintain a tag list for their own playlist, and tags may repeat within either list. To measure how similar the playlists are, count how many distinct tags appear in both lists (the size of the intersection of their distinct tag sets). Repeats never add to the count. For example, ["rock", "pop", "jazz"] and ["pop", "jazz", "folk", "pop"] share the two tags "pop" and "jazz", so the answer is 2. Return the count as an integer.
Implement
shared_tag_count(a: list[str], b: list[str]) → intExamples
in
[["rock","pop","jazz"],["pop","jazz","folk","pop"]]out2What 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 10 min
solution.py
InputExpectedGot
[["rock","pop","jazz"],["pop","jazz","folk","pop"]]2not run yetsample