C++ standard backtracking template
\nclass Solution {\npublic:\n    vector<vector<int>> result;\n    void backtrack(vector<int>& nums, vector<int> temp, int idx) {\n        result.push_back(temp)
```\nclass Solution {\npublic:\n    vector<vector<int>> result;\n    void backtrack(vector<int>& nums, vector<int> temp, int idx) {\n        result.push_back(temp);\n        if(idx >= nums.size())\n            return;\n        \n        for(int i = idx; i<nums.size(); i++) {\n            if(i > idx && nums[i] == nums[i-1]) continue; //avoid duplicates\n            \n            temp.push_back(nums[i]);     //include\n            backtrack(nums, temp, i+1);  //explore\n            temp.pop_back();             //exclude\n        }\n    }\n    vector<vector<int>> subsetsWithDup(vector<int>& nums) {\n        result.clear();\n        \n        vector<int> temp;\n        sort(begin(nums), end(nums)); //will help avoiding duplicates\n        backtrack(nums, temp, 0);\n        \n        return result;\n    }\n};\n```
[]