Rat in maze problem

where my approach is wrong ?

hello @coderajay03
a) image

here it should be <= in place of <

b)

image

here u need to make sure that index (i,j+1) or (i+1,j) is valid i.e it should not be out of the array.

c)
image
dont use return here in line 24, becuase it can happen that we get false from that function call. in that case we want next statement to execute instead of going back

modified my code as you said but bhaiya still something is wrong

check now->

1 Like

thankyou bhaiya solved **

in base case I was using return false so that I can find all other paths too

yeah to print all paths, we need to return false.
but for this problem they are asking only one valid path thats why we return true from the base case

1 Like

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.