Its not giving all testcases

Hi @Namanjain123
Your code is failing two test cases because your are using unordered_map, instead you should use map.
Because when you use unordered_map the elements are placed in map in any order while in map they are kept in sorted order. For example : when you use unordered map input
5
1
2
2
3
3
gives output as 3 but map gives output as 2.

Here is your corrected code :