Please correct my code using same approach as implemented byt me
@samadsid7
Increase your array sizes from 10 to 1000 as it is specified in the constraints you will be getting 1000 * 1000 inputs as well.
Moreover you have not covered the case when there is no path and you have to print “-1”.
Also we are required to print the rightmost path as per the problem. When you call on the right part in your code in line
bool right=path(pat,ans,i+1,j,m,n);
While you are naming it “right” , your rat is actually moving downwards. Right movement is denoted by (i,j+1) .
Similarly , in your “down” call , the rat is actually moving rat rather than down. You have inverted the two.
Since we wish to print the rightmost part , we should call on the right part first (i,j+1) .