Almost same code as subset I problem ,simple recursive cpp solution
\nclass Solution {\npublic:\n     void solve(vector<int>nums,vector<int>op,vector<vector<int>>& v)\n    {  if(nums.size()==0)\n        {   v.push_back(op);\n   
```\nclass Solution {\npublic:\n     void solve(vector<int>nums,vector<int>op,vector<vector<int>>& v)\n    {  if(nums.size()==0)\n        {   v.push_back(op);\n            return;\n        }\n        vector<int>op1;\n        vector<int>op2;\n        for(int i=0;i<op.size();i++)\n        {   op1.push_back(op[i]);\n            op2.push_back(op[i]);\n        }\n        op2.push_back(nums[0]);\n        vector<int>::iterator it;\n        it=nums.begin();\n        nums.erase(it);\n        solve(nums,op1,v);\n        solve(nums,op2,v);\n        return;\n    }\n    vector<vector<int>> subsetsWithDup(vector<int>& nums) {\n        vector<vector<int>>v;\n        vector<vector<int>>ans;\n        vector<int>op;\n        solve(nums,op,v);\n        map<vector<int>,int>mp;\n        for(int i=0;i<v.size();i++)\n        {\n            sort(v[i].begin(),v[i].end());\n            mp[v[i]]++;\n        }\n        for(auto i:mp)\n        {\n            ans.push_back(i.first);\n        }\n        return ans;\n    }\n};\n\n```\n\n**Alternate method--**\n```\nclass Solution {\npublic:\n   void backtrack(int i,vector<int>& nums,int n,vector<int>curr,vector<vector<int>>&ans)\n    {\n        ans.push_back(curr);\n        for(int j=i;j<nums.size();j++)\n        {\n            if(j>i&&nums[j]==nums[j-1])continue;\n            curr.push_back(nums[j]);\n            backtrack(j+1,nums,n,curr,ans);\n            curr.pop_back();\n        }\n    }\n    vector<vector<int>> subsetsWithDup(vector<int>& nums) {\n        int i=0;\n        sort(nums.begin(),nums.end());\n        vector<vector<int>>ans;\n        vector<int>curr;\n        int n=nums.size();\n        backtrack(i,nums,n,curr,ans);\n        return ans;\n    }\n};\n```
['Recursion', 'C', 'C++']