摘要:
这题和LeetCode第51题做法一样,只不过不是记录具体方案,而是个数。分析见第51题。 代码如下: class Solution { int res = 0; int n; vector<string> path; vector<bool> cols, diagram, anti_diagram 阅读全文
摘要:
DFS回溯,从左至右选数,加入一个一维数组oneCombination中,当oneCombination的大小等于k,表示已经选了k个数, 将oneCombination压入结果数组res中。 DFS的函数签名可以写为void DFS(int n, int k, int startPos, vect 阅读全文