标签:style blog color c for leetcode
class Solution { private: vector<vector<int> > res; public: vector<vector<int> > combine(int n, int k) { res.clear(); vector<int> path; dfs(1, n, k, path); return res; } void dfs(int lower, int upper, int level, vector<int>& path) { if (level == 0) { res.push_back(path); return; } for (int i=lower; i<= upper - level + 1; i++) { path.push_back(i); dfs(i + 1, upper, level -1, path); path.pop_back(); } } };
常规dfs
LeetCode Combinations,布布扣,bubuko.com
标签:style blog color c for leetcode
原文地址:http://www.cnblogs.com/lailailai/p/3813860.html