Only test case is passed

here is my code
it should work properly and give the desired output but it is not giving what is required may be i am missing some test case help me the code .Here is my code
"
import java.util.*;
public class Main {
public static void main(String args[]) {
Scanner scn = new Scanner(System.in);
int n = scn.nextInt();
int mat[][] = new int[n][n];
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
mat[i][j] = scn.nextInt();
}
}
int vis[][] = new int[n][n];
knightchess(mat, vis, 0, 0);
int count = 0;
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
if (mat[i][j] == 1 && vis[i][j] == 0) {
count++;
}
}
}
System.out.println(count);
}

public static void knightchess(int mat[][], int vis[][], int cr, int cc) {
	if (cr < 0 || cr >= mat.length || cc < 0 || cc >= mat[0].length) {
		return;
	}
	if (mat[cr][cc] == 0) {
		return;
	}
	if (vis[cr][cc] != 1) {
		vis[cr][cc] = 1;
		knightchess(mat, vis, cr - 2, cc - 1);// up row by 2 col left 1
		knightchess(mat, vis, cr - 2, cc + 1);// up row by 2 col right 1
		knightchess(mat, vis, cr - 1, cc - 2);// up row left col by 2
		knightchess(mat, vis, cr - 1, cc + 2);// up row right col by 2
		knightchess(mat, vis, cr + 1, cc - 2);// down row col left by 2
		knightchess(mat, vis, cr + 1, cc + 2);
		knightchess(mat, vis, cr + 2, cc - 1);
		knightchess(mat, vis, cr + 2, cc + 1);
	}
}

}

"

@guptadev354,
I have corrected your code: https://ide.codingblocks.com/s/209301

You don’t need to use vis array here, just use the mat array. Put mat[cr][cc] as 0 and then after the recursive calls for backtracking make it as 1. And keep the count variable which keeps a count on number of positions the knight can visit.