Top K Frequent Elements (LC #347) combines counting with selection. Count frequencies with a hash map in . Then find most frequent using: sorting in , min-heap of size in , or bucket sort in . For bucket sort, create buckets indexed by frequency, iterate from high frequency down, collect elements. Meta expects you to discuss tradeoffs: heap is better when is small, bucket sort when frequencies are bounded.
##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
$ curl repovive.com/roadmaps/meta-interview-prep/sorting-searching/top-k-frequent-elements
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░██████████████████████████████████████████████████████████████████████████████████████████