Rat in a maze problem


why this code is not passing all test cases

@ankit_verma according to the question, you have to print the rightmost path only, but you are printing all the possible paths.
You can add this condition after the right path, to achieve this.
image

@ankit_verma here is the complete modified code https://ide.codingblocks.com/s/256585 (you will have to change the later return statement as well)

still passing same case as before passing

@ankit_verma please see the code I attached there are a few more changes to be done

@Ishitagambhir that also not passing all test cases. or i am not understanding how you done this.

@ankit_verma share the updated code

@ankit_verma change this line, you did not add quotation marks around -1.
image

okk that’s fine but i am not understanding how you do that??

@ankit_verma what are you not able to understand?

i am confusing in right success and down success and backtracking step?? and why you return down success??

@ankit_verma if you need only the rightmost path, then once we find a path on the right, there is no need to check the down path, because we need only 1 path.
Now, lets say we did not find a path on the right side, then we need to check the down path. Whether we find a path or not can be checked by returning down_success only. Why? Because, case 1, right_success is true, then we will not get to that part because we have already returned true. case 2, right_success is false, then (A || False = A) by boolean logic, so we simply return down_success.

Have I cleared your doubt 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.