C++ subsets and subsets II almost same recursive method
Subset\n\nclass Solution{\npublic:\n\tvector<vector<int>> subsets(vector<int>& nums){\n\t\tvector<vector<int>> res;\n\t\tsubsets(res,nums,0,vector<int>());\n\t\
Subset\n```\nclass Solution{\npublic:\n\tvector<vector<int>> subsets(vector<int>& nums){\n\t\tvector<vector<int>> res;\n\t\tsubsets(res,nums,0,vector<int>());\n\t\treturn res;\n\n\t}\n\tvoid subsets(vector<vector<int>>& res,const vector<int>& nums,int pos,vector<int> temp){\n\t\tif(pos==nums.size()){\n\t\t\tres.push_back(temp);\n\t\t\treturn;\n\t\t}\n\t\tsubsets(res,nums,pos+1,temp);\n\t\ttemp.push_back(nums[pos]);\n\t\tsubsets(res,nums,pos+1,temp);\n\t}\n};\n```\nSubset 2\n\n```\nclass Solution {\npublic:\n    vector<vector<int>> subsetsWithDup(vector<int>& nums) {\n        vector<vector<int>> res;\n        sort(nums.begin(),nums.end());\n        subset(res,nums,vector<int>(),0);\n        return res;\n    }\n    void subset(vector<vector<int>>& res,const vector<int>& nums,vector<int> temp,int pos){\n        if(pos>=nums.size()){\n            res.push_back(temp);\n            return;\n        }\n        int cnt=0;\n        while(pos+cnt<nums.size()&&nums[pos]==nums[pos+cnt]){\n            cnt++;\n        }\n        subset(res,nums,temp,pos+cnt);\n        for(int i=1;i<=cnt;++i){\n            temp.push_back(nums[pos]);\n            subset(res,nums,temp,pos+cnt);\n        }\n\n\n    }\n};\n```
[]