๋ฌธ์
์ฝ๋
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 ํจ์๋ฅผ ์ฌ์ฉํ๋ฉด ์ฝ๊ฒ ํด๊ฒฐํ ์ ์์ต๋๋ค.
'Algorithm ๐ง๐ปโ๐ป > Leetcode' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[Leetcode,c++] Container With Most Water (0) | 2021.11.14 |
---|---|
[Leetcode,c++] Remove Duplicates from Sorted Array (0) | 2021.11.14 |
[Leetcode,c++] Longest Common Prefix (0) | 2021.11.11 |
[Leetcode,c++] Best Time to Buy and Sell Stock (0) | 2021.11.10 |
[Leetcode,c++] Climbing Stairs (0) | 2021.11.09 |
[Leetcode,c++] Maximum Subarray (0) | 2021.11.09 |
๋๊ธ