[C++] Easy, Clean Solution using Vector, Set and Multiset
Solution:\n\n1. Consider every subsequence as a collection of bits.\n2. 0, 1, 10, 11, 100, 101, 110, 111, and so on.\n3. We can observe that every set bit(1) in
**Solution:**\n\n1. Consider every subsequence as a collection of `bits`.\n2. 0, 1, 10, 11, 100, 101, 110, 111, and so on.\n3. We can observe that every `set bit(1)` indicates that we must include that particular element present in the array `nums` and every `unset bit(0)` indicates we must ignore that element.\n4. Check for every number which particular bit is set or unset using `i & (1 << j)`. This formula helps us to know whether to include a particular element or not.\n\n```\nclass Solution {\npublic:\n    vector<vector<int>> subsetsWithDup(vector<int>& nums) {\n        int n = nums.size();\n        int s = 1 << n;\n        set<multiset<int>> ans;\n        for(int i = 0; i < s; i++){\n            multiset<int> temp;\n            for(int j = 0; j < n; j++){\n                if(i & (1 << j))\n                    temp.insert(nums[j]);\n            }\n            ans.insert(temp);\n        }\n        vector<vector<int>> res;\n        for(auto i: ans){\n            multiset<int> temp = i;\n            vector<int> set_to_vec{temp.begin(), temp.end()};\n            res.push_back(set_to_vec);\n        }\n        return res;\n    }\n};\n```\n\n**Feel free to share your ideas or any improvements as well.**
['Bit Manipulation', 'C', 'Ordered Set']