```
public static int sum = 0;
public static int queen_num;
public static int[] x;
public static int totalNQueens(int n) {
queen_num = n;
x = new int[queen_num+1];
backtrack(1);
return sum;
}
public static void backtrack(int t){
if(t>queen_num)
sum++;
else{
for(int i = 1; i<=queen_num; i++){
x[t] = i;
if(place(t))
backtrack(t+1);
}
}
}
public static boolean place(int k){
for(int j = 1; j<k; j++){
if((Math.abs(x[j]-x[k]) == Math.abs(j-k)) || x[j] == x[k])
return false;
}
return true;
}
```

This works well on my own Java compiler and the test case, but the results don't match when I do the submission. Why??