int totalNQueens(int n) { int count = 0; vector<bool> flags(n, false); vector<bool> diag(2 * n - 1, false); vector<bool> anti_diag(2 * n - 1, false); helper(n, flags, diag, anti_diag, 0, count); return count; }
vector<vector<string>> solveNQueens(int n) { vector<vector<string>> result; if (n < 1) return result; vector<string> path; vector<bool> col(n, false); vector<bool> diag(2 * n, false); vector<bool> anti_diag(2 * n, false); dfs(result, path, col, diag, anti_diag, 0, n); return result; }
int totalNQueens(int n) { this->count = 0; if (n < 1) return this->count; vector<bool> col(n, false); vector<bool> diag(2 * n, false); vector<bool> anti_diag(2 * n, false); dfs(col, diag, anti_diag, 0, n); return this->count; }