Easy-题目40：36. Valid Sudoku

Determine if a Sudoku is valid, according to: Sudoku Puzzles - The Rules.
The Sudoku board could be partially filled, where empty cells are filled with the character ‘.’.
Note:
A valid Sudoku board (partially filled) is not necessarily solvable. Only the filled cells need to be validated.

public class Solution {
public boolean isValidSudoku(char[][] board) {
HashSet<Character> set=new HashSet<Character>();
for(int i=0;i<9;i++) {
for(int j=0;j<9;j++) {
if(board[i][j]>='0' && board[i][j]<='9') {
return false;
}
}
set.clear();
}
for(int j=0;j<9;j++) {
for(int i=0;i<9;i++) {
if(board[i][j]>='0' && board[i][j]<='9') {
return false;
}
}
set.clear();
}
for(int i=0;i<3;i++) {
for(int j=0;j<3;j++) {
for(int s=0;s<3;s++) {
for(int t=0;t<3;t++) {
if(board[i*3+s][j*3+t]>='0' && board[i*3+s][j*3+t]<='9') {
return false;
}
}
}
set.clear();
}
}
return true;
}
}

7ms,beats 35.54%,众数4ms,23.99%
Cmershen的碎碎念：

• 本文已收录于以下专栏：

举报原因： 您举报文章：Easy-题目40：36. Valid Sudoku 色情 政治 抄袭 广告 招聘 骂人 其他 (最多只允许输入30个字)