Ratinmaze backtracking

getting segmentation fault.

to remove segmentation fault
change base case
if(i==m-1 && j==n-1){
it should be double equal to

Modified Code

but this code print all possible paths
and in question you have to print only rightmost path

to print only one solution also add one condition
if(rightjao) return true;
after right call

check the code

but i>=m also means same na?

at which line??
tell the line no in modified Code

line number 18 in code

same to what??

// invalid cases.
	if(i>=m || j>=n){
		return false;
	}

this is correct

so what was the mistake earlier ?

as i mention
it was at base case
there must be double equal to
you have make single equal to

= this is for assingment
== this is for comparision

well its printing only one solution not all

this is because i have added that line

please first read my reply completely

ohh ya got it suppose in question if they asked for down then as we got solutn from down then return true na?

yes

if you have more doubts regarding this feel free to ask
i hope this helps
if yes hit a like and don’t forgot to mark doubt as resolved :grinning:

what if rat can move in all 4direction?

yes it can also happens

there is one more question in which all 4 moves are allowed
you can try this problem

not gettin that