Link: https://github.com/AlgoMaster-io/leetcode-solutions/blob/main/python/top-k-frequent-words.md
Approach 2:
if we take a look closely, then it will always pop-out the maximum frequency tuple if any smaller frequency arrives after k heappushes are done.
Which makes it wrong.
I believe it's highly unlikely to have O(nlogK) for this solution.
Instead what we can do is either of the three approaches that I have defined here: https://github.com/Rishabh-Hupr/leetcode/blob/main/heaps/top-k-frequent-elements.py