MY CODE IS GETTING CORRECT OUTPUT .BUT STILLING SOME TESTCASES

MY CODE URL IS:-https://ide.codingblocks.com/s/614865
PLZ CORRECT MISTAKES IN IT.

hi… considering the constraints we would have to take mode at every step…
u can refer to my code https://ide.codingblocks.com/s/614871

sir i understood ur code but why my code failed tp pass test cases

i am not able to understand why u are checking this last bit… simply just run a loop and compute the ans

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.