Frequency Map / Hashing
Recognize it for counting, grouping, anagram and "seen before" questions.
Frequency Map: First value seen before
3 is not in the set. Add it and move on. 1 distinct so far.
Cost
- Best
- O(n)
- Average
- O(n)
- Worst
- O(n)
- Space
- O(k)
Before this
Leads to
Topics that need this one first.