https://leetcode-cn.com/problems/valid-sudoku/
class Solution {
public boolean isValidSudoku(char[][] board) {
int n = board.length;
for(int i = 0; i < n; ++i){
Set<Character> line = new HashSet<>();
Set<Character> col = new HashSet<>();
Set<Character> subMatrix = new HashSet<>();
for(int j = 0; j < n; ++j){
Character cl = board[i][j];
Character cc = board[j][i];
/***************************************************/
Character cm = board[i / 3 * 3 + j / 3][(i % 3) * 3 + j % 3];
/***************************************************/
if(!cl.equals('.')){
if(line.contains(cl)) return false;
else line.add(cl);
}
if(!cc.equals('.')){
if(col.contains(cc)) return false;
else col.add(cc);
}
if(!cm.equals('.')){
if(subMatrix.contains(cm)) return false;
else subMatrix.add(cm);
}
}
}return true;
}
}