As we know that for this code there are multiple output , and my code also showing 4 different output , can you please correct the code.
I have written the code but multiple output
if rightsucess is true then simply return true otherwise execute next statements
The rat can move from position (i,j), down or right on the grid.
also we cant do top &left
maam what is right success , also i have removed left and top condition. still it’s not working
if your floodfill for right works .stop there and return .otherwise go for down
do like this:
bool rightsucess=floodfill(maze,row,col+1,psf+"r",visited);
if(rightsucess){
return true;
}
bool downsucess=floodfill(maze,row+1,col,psf+"d",visited);
visited[row][col]=0;
if(downsucess)
return true;
return false;
It is of void type , so return is not working
change it to bool then
Maa’m now code is running fine , but TLE is comming .
please share your final code
You have to print -1 when no solution exists.
Maa’m but as mentioned by you , I have changed the function to boolean then how i will return -1.
in the main function if your floodfill returns false ,print -1
Done maa’m still same issue.
refer to this here :
Maa’m taken help from your code , as your code was not giving right answer , but i adjust my code , now it is working fine but TLE is comming . I just have to remove TLE … MY CODE :- https://ide.codingblocks.com/s/378518
you just needed to change class name to main
here is your corrected code:
if this solves your doubt ,please mark it as resolved 
Maam string index out of bound is coming when i run your edited code . In line number 18.
it passes all the test cases for me including the sample test case
thanks maam it worked now
great! please mark your doubt as resolved 