We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 6b0871d commit 32378deCopy full SHA for 32378de
Leet_Code/Random Problem/90-SubsetsII.cpp
@@ -0,0 +1,24 @@
1
+class Solution {
2
+public:
3
+ vector<vector<int>> subsetsWithDup(vector<int>& nums) {
4
+ const int n = nums.size();
5
+ int L = (1 << n);
6
+
7
+ std::set<std::vector<int> > s;
8
9
+ for(int p = 0; p < L; p++){
10
+ int x(p);
11
+ std::vector<int> w;
12
+ for(int u = 0; u < n; u++){
13
+ if(x % 2){w.push_back(nums[u]);}
14
+ x /= 2;
15
+ }
16
+ sort(w.begin(), w.end());
17
+ s.insert(w);
18
19
20
+ std::vector<std::vector<int> > res;
21
+ for(std::set<std::vector<int>>::iterator it = s.begin(); it != s.end(); it++){res.push_back(*it);}
22
+ return res;
23
24
+};
0 commit comments