leetcode - Permutations
2017-05-19 09:09
295 查看
Given a collection of numbers, return all possible permutations.
For example,
[1,2,3]have the following permutations:
[1,2,3],
[1,3,2],
[2,1,3],
[2,3,1],
[3,1,2], and
[3,2,1].
class Solution { public: std::vector<std::vector<int> > permute(std::vector<int> &num) { std::vector<std::vector<int>> res; std::sort(num.begin(),num.end()); do { res.push_back(num); } while (std::next_permutation(num.begin(),num.end())); return res; } };
相关文章推荐
- [LeetCode][Java] Permutations
- leetcode — permutations-ii
- LeetCode 46: Permutations
- Permutations II leetcode java
- LeetCode- 46/47. Permutations/Permutations || (JAVA) (全排列1,2)
- 【Leetcode】Permutations
- leetcode--Permutations
- 【leetcode】 Permutations 一个简单next_permutation的实现
- leetcode 45: Permutations
- LeetCode 46 Permutations
- leetcode 46:Permutations
- Leetcode-46: Permutations
- LeetCode 45 Permutations
- leetcode--Permutations
- <LeetCode OJ> 46. Permutations
- [Leetcode]Permutations && Permutations II
- leetcode: Permutations
- leetcode[46]Permutations
- [LeetCode] Permutations
- Leetcode 46 - Permutations