Share my 12ms C++ solution
class Solution {\n    public:\n        vector<vector<int>> subsetsWithDup(vector<int>& nums) {\n            sort(nums.begin(), nums.end());\n            vector<
    class Solution {\n    public:\n        vector<vector<int>> subsetsWithDup(vector<int>& nums) {\n            sort(nums.begin(), nums.end());\n            vector<vector<int>> subsets;\n            vector<int> subset;\n            subsetsWithDupWorker(nums, subsets, subset, 0);\n            return subsets;\n        }\n    private:\n        void subsetsWithDupWorker(const vector<int>& nums, vector<vector<int>>& subsets, vector<int>& subset, int begin) {\n            subsets.push_back(subset);\n            for (int i = begin; i < nums.size(); i++) {\n                if (i != begin && nums[i] == nums[i-1]) continue;\n                subset.push_back(nums[i]);\n                subsetsWithDupWorker(nums, subsets, subset, i+1);\n                subset.pop_back();\n            }\n        }\n    };
[]