2 test cases are failing in the problem rat in maze

@Ashu1318 you have to check for downside ONLY if you couldnt find a path in the right side.

but i think i have done it line number 25

@Ashu1318 no, in line 22 you visited right side, and in line 23 you visited down side anyway, dont do that. Visiti downside only if right side returned false, else return true at that point itself

still not passing testcases i think i have done somthing wrong

@Ashu1318 share the updated code

@Ashu1318 still see multiple answers are being printed, you have to print only 1 path

@Ashu1318 the condition should come directly after you visited rs. The point is you DONT have to visit downside if rs returned true.
image

@Ashu1318 modify the code like this

bool rs=ratinmaze(maze,sol,i,j+1,n,m);
    if (rs) {
        return true;
    }
    bool ds=ratinmaze(maze,sol,i+1,j,n,m);
    sol[i][j]=0;
    return ds;