经典指数          
原因
961
浏览数
0
收藏数
 

Follow up for N-Queens problem. Now, instead outputting board configurations, return the total number of distinct solutions.

     举报   纠错  
 
切换
1 个答案
class Solution { int N=0,A[10]; public: int totalNQueens(int n) { build(0,n); return N; } int jue(int x) { return x>=0?x:-1*x; } void build(int step,int n) { int i,j; if(step==n) N++; else { for(i=0;i
 
切换
撰写答案