c ++ recursive solution || 100 % beat || easy to understand
Code\n\nclass Solution {\nprivate:\n\n    void subset(int index,vector<int>&nums,vector<int>&ds,vector<vector<int>>&ans){\n        ans.push_back(ds);\n        f
# Code\n```\nclass Solution {\nprivate:\n\n    void subset(int index,vector<int>&nums,vector<int>&ds,vector<vector<int>>&ans){\n        ans.push_back(ds);\n        for(int i=index;i<nums.size();i++){\n            if(i!=index && nums[i]==nums[i-1]) continue;\n            ds.push_back(nums[i]);\n            subset(i+1,nums,ds,ans);\n            ds.pop_back();\n        }\n    }\npublic:\n    vector<vector<int>> subsetsWithDup(vector<int>& nums) {\n        vector<vector<int>>ans;\n        vector<int>ds;\n        sort(nums.begin(),nums.end());\n        subset(0,nums,ds,ans);\n        return ans;\n    }\n};\n```
['Recursion', 'C++']