3 test cases are not passing

Hi @abhi542136… Just go through my soln once… https://ide.codingblocks.com/s/594638
I have explained the whole thing using comments

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.

I have applied the same logic as told in the hint video… but why it is not passing all the test cases?? your code is right, but where is the mistake in my code??