educative.io

Why doesn't my heapsort work?

Hey all, working through the Frequency Sort problem, and unsure why my solution gives incorrect output for certain inputs. It SEEMS logically equivalent to the solution given in the guide, but something is apparently amiss:

My Solution

Output:

Thanks!

Hi @Tom

I am unable to find the lesson for which the heapsort code didn’t work. Could you please provide me with the direct link to that lesson so I can look into it?
thanks!

Hey @Usman_Younas , sure. The lesson is here: Frequency Sort (medium) - Grokking the Coding Interview: Patterns for Coding Questions