https://leetcode.com/problems/subsets/

Source


    void DFS(vvi& vviSubsets, vi viSubset, const vi& nums, const int idx) {
        vviSubsets.push_back(viSubset);
        for (int i=idx; i<nums.size(); ++i) {
            viSubset.push_back(nums[i]);

            DFS(vviSubsets, viSubset, nums, i+1);

            viSubset.pop_back();
        }
    }

GitHub

Subsets