I have tried the same using recursion

showing runtime error please help

Hi @chemant077,
I hv updated ur code, have a look at it. If u still feel like something is unclear, post ur doubts here.


in ur code,
1)while printing matrix, u wore printing maze[row][column] instead of maze[i][j].
2)in ur function, when u go out of maze i.e x>n or y>m, return 0 instead of returning findpath(maze,x+1,y,xf,yf), since u would have already taken that into consideration in previous steps(try more to think about it. If still unclear, pls post it here i will try to explain in brief).
3)try using x>n or y>m base case before checking maze[x][y]==-1 since if x>n or y>m maze[x][y] will give an error.
also try to use dp here. while submitting it might give tle.
and take %1000000007 wherever required as mentioned in question.

thanks bro well explaiend<3