Whats the error in this?

@Namanjain123
hello Naman,
ur code is running in infinit loop.

for example if u are at (i,j)
a) from -> i,j we can reach (i-1,j) ,(i,j+1),(i+1,j), (i,j-1)

b) now consider (i+1,j) -> (i,j) , (i+2,j),(i+1,j-1) ,(i+1),(j-1)

again from (i,j)-> same story it will give (i+1,j) which will again give (i,j) and this loop will run for infinite time

but when i come from i+1,j to i,j with true value then it will return true to previous call it wont go to the calls beneath it??? i will go below only when we return with false value??

@Namanjain123
but when i+1,j will return false u will again come back to i,j and again same trversal will start

to avoid it just add this extra condition
image

thanks got the reason of error

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.