首页 > 其他分享 >LeetCode 78 子集

LeetCode 78 子集

时间:2022-09-05 08:58:48浏览次数:60  
标签:nums res back dfs vector 子集 path LeetCode 78

class Solution {
public:
    vector<vector<int>> res;
    vector<int> path;

    void dfs(int start, vector<int>& nums) {
        res.push_back(path);

        for (int i = start; i < nums.size(); i ++ ) {
            path.push_back(nums[i]);
            dfs(i + 1, nums);
            path.pop_back();
        }

    }
    vector<vector<int>> subsets(vector<int>& nums) {
        dfs(0, nums);

        return res;
    }
};

标签:nums,res,back,dfs,vector,子集,path,LeetCode,78
From: https://www.cnblogs.com/hjy94wo/p/16656823.html

相关文章