What this problem teaches: Two-pass pattern. When you need global information before local decisions, scan twice: once to gather data, once to use it.
Dictionaries for counting. The counts.get(char, 0) + 1 pattern handles first occurrences cleanly.
Sets aren't enough here. A set tells you whether a character exists, not how many times. Counting needs a dictionary. This problem combines dictionary skills (from last section) with the concept of uniqueness (sets). As problems get harder, you'll combine more data structures.