feat: 46_permutations
This commit is contained in:
parent
a41c9a4e18
commit
bb048062c4
17
46_permutations/main.cpp
Normal file
17
46_permutations/main.cpp
Normal file
@ -0,0 +1,17 @@
|
||||
#include <bits/stdc++.h>
|
||||
using namespace std;
|
||||
|
||||
class Solution {
|
||||
public:
|
||||
vector<vector<int>> permute(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