Highest frequency

Why I am getting wrong output for testcase 0 and testcase 1 ?

@vaishnavtannu
Line 16
Use map not unordered_map

Yes, it got accepted by using map. But can you please explain the reason why using unordered_map will result into wrong answer ?

@vaishnavtannu
When more than 1 value have the same frequency, then the number with lower value is picked. In map numbers are already stored in increasing order so the code works fine.

Please close the doubt if your query is resolved