Https://www.hackerearth.com/challenges/competitive/codemonk-sorting/algorithm/monk-being-monitor/description/

found this ques on codemonk. getting wrong answer for a test case. kindly check if my code is wrong or the problem has some error.

https://ide.codingblocks.com/s/346060

The approach you used is very complex. Simply store all the heights in a map. Then traverse the map for maximum and minimum frequency keeping in mind h1>h2. And display the difference.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.