Follow up for N-Queens problem.
Now, instead outputting board configurations, return the total number of distinct solutions.
'Q' and '.' both indicate a queen and an empty space respectively.[ [".Q..", // Solution 1 "...Q", "Q...", "..Q."], ["..Q.", // Solution 2 "Q...", "...Q", ".Q.."] ]
'.'."((()))", "(()())", "(())()", "()(())", "()()()"0-9 only, each root-to-leaf path could represent a number.1->2->3 which represents the number 123.1 / \ 2 3
1->2 represents the number 12.1->3 represents the number 13.25.sum = 22, 5
/ \
4 8
/ / \
11 13 4
/ \ / \
7 2 5 1
return[ [5,4,11,2], [5,8,4,5] ]
[ [2,4], [3,4], [2,3], [1,2], [1,3], [1,4], ]