Rat in a maze backtracking

pls point out the mistakes in my code

Hello keshav, actually you are printing all possible solution but you just have to print one solution. So if you find solution by moving in right direction you need not to move to down direction. Just write if(right){ return true; } after line no 32.t
There is mistake in line 9, it should be out[i][j]=1; not “==”.
Also you have to print space while printing your final ans, so line 15 should be cout<<out[q][w]<<" ";