# My java Solution

• `````` import java.util.Hashtable;
public class Solution {
public boolean isValidSudoku(char[][] board) {
//对所有的行和列进行一个判断
for(int i=0;i<9;i++)
{	Hashtable<Character,Integer> table1 = new Hashtable();
Hashtable<Character,Integer> table2 = new Hashtable();
for(int j =0;j<9;j++)
{

if(board[i][j] !='.')
{
Integer put = table1.put(board[i][j], j);
if(put != null)
return false;
}

if(board[j][i]!='.'){
if(board[j][i] == '5'){
System.out.print("This is 5");
}
Integer put2 = table2.put(board[j][i], j);
if(put2 != null)
return false;
}
}
}
//对9宫格进行一个判断
Hashtable<Character,Integer> table = new Hashtable();
for(int i=0;i<3;i++)
{
for(int j=0;j<3;j++)
{
if(board[i][j] != '.')
{
Integer put = table.put(board[i][j], i);
if(put != null)
return false;
}
}
}
Hashtable<Character,Integer> table2 = new Hashtable();
for(int i=0;i<3;i++)
{
for(int j=3;j<6;j++)
{
if(board[i][j] != '.')
{
Integer put = table2.put(board[i][j], i);
if(put != null)
return false;
}
}
}
Hashtable<Character,Integer> table3 = new Hashtable();
for(int i=0;i<3;i++)
{
for(int j=6;j<9;j++)
{
if(board[i][j] != '.')
{
Integer put = table3.put(board[i][j], i);
if(put != null)
return false;
}
}
}

Hashtable<Character,Integer> table4 = new Hashtable();

for(int i=3;i<6;i++)
{

for(int j=0;j<3;j++)
{
if(board[i][j] != '.')
{
Integer put = table4.put(board[i][j], i);
if(put != null)
return false;
}
}
}
Hashtable<Character,Integer> table5 = new Hashtable();
for(int i=3;i<6;i++)
{
for(int j=3;j<6;j++)
{
if(board[i][j] != '.')
{
Integer put = table5.put(board[i][j], i);
if(put != null)
return false;
}
}
}
Hashtable<Character,Integer> table6 = new Hashtable();
for(int i=3;i<6;i++)
{
for(int j=6;j<9;j++)
{
if(board[i][j] != '.')
{
Integer put = table6.put(board[i][j], i);
if(put != null)
return false;
}
}
}
Hashtable<Character,Integer> table7 = new Hashtable();
for(int i=6;i<9;i++)
{
for(int j=0;j<3;j++)
{
if(board[i][j] != '.')
{
Integer put = table7.put(board[i][j], i);
if(put != null)
return false;
}
}
}
Hashtable<Character,Integer> table8 = new Hashtable();
for(int i=6;i<9;i++)
{
for(int j=3;j<6;j++)
{
if(board[i][j] != '.')
{
Integer put = table8.put(board[i][j], i);
if(put != null)
return false;
}
}
}
Hashtable<Character,Integer> table9 = new Hashtable();
for(int i=6;i<9;i++)
{
for(int j=6;j<9;j++)
{
if(board[i][j] != '.')
{
Integer put = table9.put(board[i][j], i);
if(put != null)
return false;
}
}
}
return true;
}
``````

}

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.