https://ide.codingblocks.com/s/79781 code is giving no-output for 3rd testcase
Rat chase its cheese
Ajit, you need to maintain a visited path, initialise it to 1 when you have taken the solution matrix to be 1, as its mentioned in the problem that you have to print the extreme rightmost path only, so for that , you need to only include two conditions as,
if(visited[i][j+1]==false && solution[i+1][j]==0)
{
downSuccess=ratmaze(maze,solution,i+1,j,N,M);
}
if(visited[i][j+1]==false && solution[i][j+1]==0)
{
rightSuccess=ratmaze(maze,solution,i,j+1,N,M);
}
Rest code remains same,… try to implement this logic…along with your code…
this is another question of Rat maze in which rat can move anywhere right,left,top.down.
Yes, you can move in all 4 directions, What i suggested you was that in the question, its written that out of all the paths, you have to print only the rightmost path, and thats why for that there is a need to maintain a visited path array and before moving downwards or rightwards, you need to check if the path is already visited earlier or not and based on that the solution will be printed…