What did you learn? Complex problems often combine data structures. Here: hash map for counting, heap for selection.
Heaps can order by any property, not just element value. Here: order by frequency.
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.