Follow up for N-Queens problem.
Now, instead outputting board configurations, return the total number of distinct solutions.
#include#include #include using namespace std;class Solution{public: int res=0; int totalNQueens(int n) { vector state(n,-1); helper(n,0,state); return res; } void helper(int n,int start,vector &state) { if(start==n) { res++; return; } int i; for(i=0; i