C++ backtracking set 3ms
Runtime: 3 ms, faster than 73.08% of C++ online submissions for Subsets II.\nMemory Usage: 7.8 MB, less than 54.76% of C++ online submissions for Subsets II.\n\
**Runtime:** 3 ms, faster than 73.08% of C++ online submissions for Subsets II.\n**Memory Usage:** 7.8 MB, less than 54.76% of C++ online submissions for Subsets II.\n```\nclass Solution {\npublic:\n    vector<vector<int>> subsetsWithDup(vector<int>& nums) {\n        set<vector<int>> ans;\n        vector<int> curr;\n        vector<vector<int>> ret;\n        \n        sort(nums.begin(), nums.end());\n        backtrack(ans, curr, nums, 0);\n        ret.assign(ans.begin(), ans.end());\n        return ret;\n    }\n    void backtrack(set<vector<int>>& ans, vector<int>& curr, vector<int>& nums, int pos) {\n        if(pos == nums.size()) {\n            ans.insert(curr);\n            return;\n        }\n        curr.push_back(nums[pos]);\n        backtrack(ans, curr, nums, pos + 1);\n        curr.pop_back();\n        backtrack(ans, curr, nums, pos + 1);\n    }\n};\n```
['Backtracking', 'C', 'Ordered Set', 'C++']