public boolean isValid(int[][] board, int row, int column) {
        // check row
        for (int i = 0; i < board.length; ++i) {
            if (board[i][column] == 1)
                return false;
        }
        for (int i = 0; i < board[0].length; ++i) {
            if (board[row][i] == 1)
                return false;
        }

        for (int i = 0; i < board.length; ++i) {
            for (int j = 0; j < board[0].length; ++j) {
                if (board[i][j] == 1 && (row - i == column - j || row - i == (j - column))) {
                    return false;
                }
            }
        }
        return true;
    }