Rat in maze problem 1

https://ide.geeksforgeeks.org/x0shLpvjcD---------what’s the error in my code please make corrections

@AbhishekAhlawat1102 in your line 38 and 41 when u are passing getpath for c+1 or y+1 ,the loop is calling getpath for n+1 and m+1 of the array too(when we have reached the last block).that does not exist.that is why u are getting NoSuchElementException error .try to ammend that

but i m already taking care of it in my base case in line 32?

@AbhishekAhlawat1102 take ur case for loop
if(isSafe(arr,x,y)){
sol[x][y] = 1;
if(getPath(arr,x+1,y,sol)){
return true;
}
when u reach the last block,it satisfies issafe,you mark it as 1 and then u check for getPath(arr,x+1,y,sol) which does not exist