Why only passing only two test cases?

Here i had done everything as possible still not getting all test cases passed

Hello @ssanjuchandra, the problem is coming due to the global vector you are using. In the next recursive call the values get erased or get updated by the next call and so your ans is not coming right.
Pls refer this…


I modified your code it is now working fine…

In case if it is clear to you pls mark it as resolved. And let me know if there is any confusion.

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.