Regarding TLE in the problem

Sir 3 out of 4 test cases are fine. One is showing TLE. I am unable to find some other alternative