Please solve the error in this code

hello @anshulgurawalia

check now->

see this code i am not getting the same output

line 51, u should pass index in place of index -1. becuase in the loop u r not including ur last index

now its not passing all test cases

check now->

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.