这道题仅仅是判断是否能解开数独 不要求解出来
class Solution { public boolean isValidSudoku(char[][] board) { for(int i = 0 ; i < 9 ;i++) { for(int j = 0 ; j < 9 ; j++) { char temp = board[i][j]; board[i][j]='.'; for(int x = 0 ; x < 9 ;x++) { if(board[i][x]==temp||board[x][j]==temp) return false; } for(int x = 0 ; x < 3 ; x++) { for(int y = 0 ; y < 3 ; y++) { if(board[i/3*3+x][j/3*3+y]==temp) return false; } } board[i][j] = temp; } } return true; } }
class Solution {
public boolean isValidSudoku(char[][] board) {
for(int i = 0; i < 9; i++){
for(int j = 0; j < 9; j++){
if(board[i][j] == '.')continue;
for(int k = 8; k > j; k--)
if(board[i][j] == board[i][k])
return false;
for(int k = 8; k > i; k--)
if(board[i][j] == board[k][j])
return false;
for(int k = i + 1; k % 3 != 0; k ++){
for(int h = j / 3 * 3;h < j / 3 * 3 + 3; h ++ )
if(board[i][j] == board[k][h])
return false;
}
}
}
return true;
}}
```