I wrote the code for a question I got on Hackerearth. But my code is showing partially correct. Can you please help me figuring out my mistake in the approach!

Above I have given the link to the question.
Below I attach my code.
https://ide.geeksforgeeks.org/QxGIDUTswF

Please help me in figuring out my mistake

Can Anyone please help me out in the above question!!!

Edit: Anyone from team coding blocks !! …please help!!..I have been getting very prompt reply from your side everytime…please help me out this time too!