LeetCode_46---Permutations
来源:互联网 发布:社交网络 网盘 编辑:程序博客网 时间:2024/06/06 12:39
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]
.
翻译:
Code:
LinkedList<List<Integer>> res = new LinkedList<List<Integer>>();res.add(new ArrayList<Integer>());for (int n : nums) {int size = res.size();for (; size > 0; size--) {List<Integer> r = res.pollFirst();for (int i = 0; i <= r.size(); i++) {List<Integer> t = new ArrayList<Integer>(r);t.add(i, n);res.add(t);}}}return res;
0 0
- LeetCode_46---Permutations
- LeetCode_46 Permutations
- Permutations
- Permutations
- Permutations
- Permutations
- Permutations
- Permutations
- Permutations
- Permutations
- Permutations
- Permutations
- Permutations
- Permutations
- Permutations
- Permutations
- Permutations
- Permutations
- 决策树之ID3、C4.5、C5.0算法
- HTTP请求的TCP瓶颈分析
- STL之二分查找
- oracle 日期格式(比较全)
- extern
- LeetCode_46---Permutations
- 常用宏
- MySQL 的 RowNum 实现
- 2015年6月24日日报
- Unity3d简单json库中SimpleJSON.cs源码
- 黑马程序员--oc分类
- 《重构--改善既有代码的设计》--重构列表(5)
- PHP运行出现Notice : Use of undefined constant 的解决办法
- iOS-Core-Animation-Advanced-Techniques(四)