please tell where i am wrong?
Top k most frequent
Hey, i couldn’t understand your logic.Could you please explain your logic a bit?
This is my code.It is accepted.
i have made some changes please check this code.
i am using pair to store number and its frequency and each time it takes input from user ,i sort the pair according to frequency in desc order and in asc order if frequency is same.if any number is repeating ,i update its frequency and set the frequency of newly added repeated number to -1 to not access it later. after sorting i print 1st k pair elements
https://ide.codingblocks.com/s/251327 now All the three cases’ output are matching with your code’s output