Two test cases give wrong output i tried a lot to figure out the problem can you please help me out

Rajat can u pls tell the approach you have used in your code .