Please check the code its failing two tcs

hello @sneha23
check now->

a) u were declaring new dp array for each new function call.

b) use -1 in place of 0 to indicate unvisited state . we cant use 0 becuase it can be a valid answer

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.