# What's wrong with my code?

• public class Solution {
public boolean isValidSudoku(char[][] board) {
int flag=0;
for(int i=0;i<9;i++)
{
HashMap<Integer, Character> map = new HashMap<Integer, Character>();
for(int j=0;j<9;j++)
if(checknum(board[i][j])&&!map.containsValue(board[i][j]))
map.put(j,board[i][j]);
else
flag=1;

``````}
for(int j=0;j<9;j++)
{
HashMap<Integer, Character> map = new HashMap<Integer, Character>();
for(int i=0;i<9;i++)
if(checknum(board[i][j])&&!map.containsValue(board[i][j]))
map.put(i,board[i][j]);
else
flag=1;
}
for(int i=0;i<3;i++)

for(int j=0;j<3;j++)
{
HashMap<Integer, Character> map = new HashMap<Integer, Character>();
for(int k=3*i;k<3+3*i;k++)

for(int l=3*j;l<3*j+3;l++)
{

int key;
if(checknum(board[k][l])&&!map.containsValue(board[k][l]))
{
key=(int)board[k][l]-'1';
map.put(key,board[k][l]);
}
else
flag=1;
}
}

if(flag==0)
return true;
else
return false;
``````

}

static boolean checknum(char n)
{
int c=(int) n-'1';
if(c>=0&&c<=9)
return true;
else if(n=='.')
return true;
return false;
}
}

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