Error while running the program

Can you please figure out the issue with my solution

@indrabijaynarayan,
Please share your code as well.

public static void main(String[] args) { // TODO Auto-generated method stub Scanner sc = new Scanner(System.in); System.out.println(“Enter the total Columns”); int col = sc.nextInt(); System.out.println(“Enter the total row”); int row = sc.nextInt(); char [][] board = new char[row][col]; for(int r=0;r<row;r++){ for(int c=0;c<col;c++){ System.out.println("Enter the value for row: "+r + " column: "+c); board[r][c]= sc.next().charAt(0); } } //int[][] board = {{0,‘X’,0,0}, {0,0,0,0}, {0,‘X’,0,0}, {0,0,‘X’,0}}; blockMazeWR(board, 0,0, “”); } public static void blockMazeWR(char [][] maze, int row, int col, String ans){ if(row == maze.length-1 && col == maze[0].length-1){ if(ans.length()>0){ System.out.println(ans); } else{ System.out.println(-1); } return; } if(row==-1 || row == maze.length || col == -1 || col == maze[0].length || maze[row][col]==‘X’){ //System.out.println(-1); return; } if(maze[row][col]==‘O’){ //place // //Top //blockMazeWR(maze, row-1, col, ans+“T”, visited); //Down blockMazeWR(maze, row+1, col, ans+“1”); //Left //blockMazeWR(maze, row, col-1, ans+“L”, visited); //Right blockMazeWR(maze, row, col+1, ans+“1”); //visited[row][col] = false; } }

@indrabijaynarayan,
Can you share via https://ide.codingblocks.com/
The code is not at all in a readable format.

how can I share my code.

@indrabijaynarayan,
open https://ide.codingblocks.com/
select correct language.
paste your code.
press ctrl+s and then click on save.
share the link.

Please help me , how can I resolve this issue

@indrabijaynarayan,
First, what are you taking input in n as?

You need only input of row and col. Also, don’t print statements like these: " // System.out.println(“Enter the total row”);"

You need to follow the format given in the sample test case.

Also in the input format, first take input of row then column. And you have taken input of a char array but passed the board array as int. So please correct that as well.

Suggested approach:
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

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.