class Solution {
public boolean isValidSudoku(char[][] board) {
int n = board.length;
int[][] row = new int[n][n];
int[][] col = new int[n][n];
int[][] box = new int[n][n];
for (int i = 0; i < n; i++) {
for(int j=0;j < n;j++){
if (board[i][j]=='.')continue;
int tmp = board[i][j]-'1';
if (row[i][tmp]==1 ||col[j][tmp]==1 ||box[i/3+j/3*3][tmp]==1)return false;
row[i][tmp]=1;
col[j][tmp]=1;
box[i/3+j/3*3][tmp]=1;
}
}
return true;
}
}
二维数组 第一维是位置,第二维是位置上的数字
每个位置对应的数字不可相同
比如第二行的5只能有一个