Follow up for N-Queens problem.
Now, instead outputting board configurations, return the total number of distinct solutions.
class Solution {public:void init(vector&temp, int n){ string strtemp(n,'.'); temp.insert(temp.end(),n,strtemp); return;}bool checkij(vector &temp, int i, int j){ for (int ii=i-1,jleft=j-1;ii>=0&&jleft>=0;ii--,jleft--) { if(temp[ii][jleft]=='Q')return false; } for (int ii=i-1,jright=j+1;ii>=0&&jright &temp,int n, int index){ if(index==n) { res++; return true; } for (int j=0;j temp; init(temp,n); for(int i=0;i