private boolean check(char[][]board, int i, int j) {
        boolean check[] = new boolean[9];
        // check row
        for (int x = 0; x < 9; x ++) {
            if (board[i][x] == '.') {
                continue;
            } else if (check[board[i][x] - '1']) {
                return false;
            }
            check[board[i][x] - '1'] = true;
        }
        // check column
        Arrays.fill(check, false);
        for (int y = 0; y < 9; y ++) {
            if (board[y][j] == '.') {
                continue;
            } else if (check[board[y][j] - '1']) {
                return false;
            }
            check[board[y][j] - '1'] = true;
        }
        // check 3x3
        Arrays.fill(check, false);
        int si = i - i % 3, sj = j - j % 3; 
        for (int d = 0; d < 9; d ++) {
            int y = si + d / 3, x = sj + d % 3;
            if (board[y][x] == '.') {
                continue;
            } else if (check[board[y][x] - '1']) {
                return false;
            }
            check[board[y][x] - '1'] = true;
        }
        return true;
    }