feat: 47_permutations_2
This commit is contained in:
parent
bb048062c4
commit
3fb7c796f4
17
47_permutations_2/main.cpp
Normal file
17
47_permutations_2/main.cpp
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
#include <bits/stdc++.h>
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
class Solution {
|
||||||
|
public:
|
||||||
|
vector<vector<int>> permuteUnique(vector<int>& nums) {
|
||||||
|
vector<vector<int>> result;
|
||||||
|
|
||||||
|
sort(nums.begin(), nums.end());
|
||||||
|
result.emplace_back(nums);
|
||||||
|
|
||||||
|
while (next_permutation(nums.begin(), nums.end())) {
|
||||||
|
result.emplace_back(nums);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
};
|
Loading…
x
Reference in New Issue
Block a user