Valid Sudoku
The Sudoku board could be partially filled, where empty cells are filled with the character '.'
.
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 public class Solution { 2 public boolean isValidSudoku(char[][] board) { 3 for(int i=0;i<9;i++){ 4 int []row = new int[10]; 5 int []col = new int[10]; 6 for(int j=0;j<9;j++){ 7 if(board[i][j]!='.') 8 { 9 if(col[board[i][j]-'0']==1)return false; 10 else{ 11 col[board[i][j]-'0']++; 12 } 13 } 14 if(board[j][i]!='.'){ 15 if(row[board[j][i]-'0']==1) return false; 16 else{ 17 row[board[j][i]-'0']++; 18 } 19 } 20 } 21 } 22 for(int i=0;i<9;i+=3){ 23 for(int j=0;j<9;j+=3){ 24 int[] row = new int[10]; 25 for(int m=0;m<3;m++){ 26 for(int n=0;n<3;n++){ 27 if(board[i+m][j+n]=='.') continue; 28 else{ 29 if(row[board[i+m][j+n]-'0']==1)return false; 30 else row[board[i+m][j+n]-'0']++; 31 } 32 } 33 } 34 } 35 } 36 return true; 37 } 38 }