Top K Frequent Elements — JavaScript medium interview problem
Given an integer array `nums` and an integer `k`, return the `k` most frequent elements. You may return the answer in any order. Example: `topKFrequent([1,1,1,2,2,3], 2)` → `[1,2]`.
Tags: hashmap, heap, bucket
Practice this HashMap & Set problem free in the JS Interview Playground with automated tests and unlockable solutions.