Help me to optimize my code

i have completed this challenge
but i want more efficient ans
here is my code-

hi @sakshamngplsn_8a4528baa287a8ff
ur code seems efficient only… its O(N) soln, so its good complexity only…

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.