Sort Game - Tried Different Approach1

I tried to solve this question using maps but unable to pass all the test cases. Can you please check my code and tell where am I wrong?