valid sudoku leetcode
user_0428979054
java
4 years ago
867 B
15
Indexable
class Solution {
public boolean isValidSudoku(char[][] board) {
byte[][] c = new byte[9][10];
byte[] r = null;
byte[][] b = null;
for(int i = 0; i < 9; i++ ){
r = new byte[10];
for(int j = 0; j < 9; j++){
if(i % 3 == 0 && j == 0){
b = new byte[3][10];
}
if(board[i][j] == '.'){
continue;
}
byte t = (byte)(board[i][j] - 48);
if(c[j][t] == t
|| r[t] == t
|| b[j/3][t] == t){
return false;
}
c[j][t] = b[j/3][t] = r[t] = t;
}
}
return true;
}
}Editor is loading...