Some test cases are passing and some not, any suggestions

import java.io.;
import java.util.
;
public class Main {
static int visited[][]=new int[1001][1001],solution[][]=new int[1001][1001];

public static void main(String args[]) throws IOException {
    // Your Cod
int n,m;

BufferedReader ob = new BufferedReader(new InputStreamReader(System.in));
Scanner sc=new Scanner(System.in);
m=sc.nextInt();
n=sc.nextInt();
char maze[][]=new char[m+1][n+1];
for(int i=0;i<m;i++)
{
for(int j=0;j<n;j++)
{
maze[i][j]=sc.next().charAt(0);
if(maze[i][j]==‘X’)
visited[i][j]=1;
}
}
m–;
n–;
boolean Y = RatinMaze(maze,0,0,m,n);
if(Y==false){
System.out.println(-1);
}
}
public static boolean RatinMaze(char maze[][], int i,int j,int m, int n){
if(i==m && j==n){
solution[i][j] = 1;
for(int x=0;x<=m;x++){
for(int y=0;y<=n;y++){
System.out.print(solution[x][y]);
}
System.out.println();
}
return true;
}

if(visited[i][j]==1){
    return false;
}

visited[i][j]=1;
solution[i][j] = 1;
    if(j+1<=n && visited[i][j+1]==0){
            boolean rightsuccess = RatinMaze(maze,i,j+1,m,n);
            if(rightsuccess==true){
                return true;
            }
    }
    if(i+1<=m && visited[i+1][j]==0){
            boolean downsuccess = RatinMaze(maze,i+1,j,m,n);
            if(downsuccess==true){
                return true;
            }
    }
solution[i][j] = 0;
return false;

}

}

Your code is fine
there are just some syntax error while u r taking input and
make the maze arr of size m and n

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.