private boolean solve(char[][] board) {
        for (int row = 0; row < 9; ++row) {
            for (int col = 0; col < 9; ++col) {
                if (board[row][col] == '.') {
                    for (char n = '1'; n <= '9'; ++n) {
                        if (isValid(board, row, col, n)) {
                            board[row][col] = n;
                            if (solve(board)) return true;
                            board[row][col] = '.';
                        }
                    }
                    return false;
                }
            }
        }
        return true;
    }