Algorithm π§π»π»/Leetcode
[Leetcode,c++] Permutations
dkswnkk
2021. 11. 10. 23:43
λ¬Έμ
Permutations - LeetCode
Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview.
leetcode.com
μ½λ
class Solution {
public:
vector<vector<int>> permute(vector<int>& nums) {
vector<vector<int>>ans;
sort(nums.begin(),nums.end());
do{
ans.push_back(nums);
}while(next_permutation(nums.begin(),nums.end()));
return ans;
}
};
νμ΄
λ¨μνκ² μμ΄μ ꡬνλ λ¬Έμ μ λλ€. algorithm ν€λ νμΌμ λ΄μ₯λμ΄μλ net_permutation ν¨μλ₯Ό μ¬μ©νλ©΄ μ½κ² ν΄κ²°ν μ μμ΅λλ€.