I am not getting it's approach

can u explain sol of this

public class MazeRat { public static void main(String[] args) { int[][] maze=new int[4][5]; int[][]sol=new int[4][5]; int maze1[][]= {{0,1,0,0},{0,0,0,1},{0,0,1,0},{1,0,0,0},{1,1,0,0}}; ratMaze(maze1,0,0,sol); // TODO Auto-generated method stub } public static void ratMaze(int[][]maze,int row,int col,int[][]sol) { if(row==maze.length-1 && col==maze[0].length-1) { sol[row][col]=1; return; } if(row>=maze.length) { return; } if(isItSafe(maze,row,col)) { sol[row][col]=1; ratMaze(maze,row,col+1,sol); } ratMaze(maze,row+1,col,sol); sol[row][col]=0; } public static boolean isItSafe(int[][]maze,int row,int col) { if(col<maze[0].length || maze[row][col]==1) { return false; } return true; }

please share your code after saving it on ide.codingblocks.com

If destination is reached print the solution matrix .
Else .
a) Mark current cell in solution matrix as 1.
b) Move forward in the horizontal direction and recursively check if this move leads to a solution.
c) If the move chosen in the above step doesn’t lead to a solution then move down and check if this move leads to a solution.
d) If none of the above solutions works then unmark this cell as 0 (BACKTRACK) and return false