Valid Sudoku

给一个2d数组, 是数独的数组, 求是否是一个正确的数独.

public class Solution {
    public boolean isValidSudoku(char[][] board) {
        boolean[] visited = new boolean[9];
        for(int i = 0 ; i < 9; i++) {
            Arrays.fill(visited,false);
            for(int j = 0 ; j < 9; j++)
                if(!check(visited,board[i][j]))
                    return false;
        }
        for(int i = 0 ; i < 9; i++) {
            Arrays.fill(visited,false);
            for(int j = 0 ; j < 9; j++)
                if(!check(visited,board[j][i]))
                    return false;
        }
        for(int i = 0 ; i < 9; i+=3) {
            for(int j = 0 ; j < 9; j+=3){
                Arrays.fill(visited,false);
                for(int k = 0; k < 9; k++){
                if(!check(visited,board[i+k/3][j+k%3]))
                    return false;
                }
            }
        }
        return true;
    }
    
    public boolean check(boolean[] visited, char digit) {
        if(digit == '.')
            return true;
        int n = digit - '0';
        if(n > 9 || n < 1 || visited[n-1])
            return false;
        visited[n-1] = true;
        return true;
    }
}