public class Main {
static int n;
public static void printsol(int sol[][]){
for(int i=0;i<n;i++){
for(int j=0;j<n;j++)
System.out.print(" “+sol[i][j] +” ");
System.out.println();
}
}
public static boolean issafe(int maxe[][],int x,int y){
return(x>=0 && x<n && y>=0 && y<n && maxe[x][y]==1);
}
public static boolean solvemazeutil(int maze[][],int x,int y,int sol){
if(x==n-1 && y==n-1){
sol[x][y]=1;
return true;
}
if(issafe(maze,x,y)==true){
sol[x][y]=1;
if(solvemazeutil(maze,x+1,y,sol))
return true;
if(solvemazeutil(maze,x,y+1,sol))
return true;
sol[x][y]=0;
return false;}return false;}
public static boolean solveMaze(int maze[][]){
int sol[][]=new int[n][n];
if(solvemazeutil(maze,0,0,sol)==false){
return false;
}
printsol(sol);
return true;
}
public static void main(String args[]) {
int maze[][] = { { 1, 0, 0, 0 },
{ 1, 1, 0, 1 },
{ 0, 1, 0, 0 },
{ 1, 1, 1, 1 } };
n = maze.length;
solveMaze(maze);
}
}
what is problem in my code