Data Structures19 sections · 729 units
Open in Course

Lessons from Top K Frequent

Combining structures

What did you learn?

1.1. Complex problems often combine data structures. Here: hash map for counting, heap for selection.

2.2. Heaps can order by any property, not just element value. Here: order by frequency.

3.3. When using pairs in heaps, the first element determines ordering. Put the comparison key first. This combination (count with map, select with heap) appears in many problems.