Permutations
来源:互联网 发布:智业软件薪资 编辑:程序博客网 时间:2024/05/21 11:08
public ArrayList<ArrayList<Integer>> permute(int[] num) { ArrayList<ArrayList<Integer>> res = new ArrayList<ArrayList<Integer>>(); if(num==null || num.length==0) return res;ArrayList<Integer> t = new ArrayList<Integer>(); t.add(num[0]); res.add(t); for(int i=1;i<num.length;i++){ res = helper(res,num[i]); } return res; } public ArrayList<ArrayList<Integer>> helper(ArrayList<ArrayList<Integer>> res, int k){ ArrayList<ArrayList<Integer>> list = new ArrayList<ArrayList<Integer>>(); for(int i=0;i<res.size();i++){ for(int j=0; j<= res.get(i).size(); j++){ ArrayList<Integer> item = new ArrayList<Integer>(res.get(i)); item.add(j, k); list.add(item); } } return list; }
1) 插入法
2) 不需要删除什么
0 0
- Permutations
- Permutations
- Permutations
- Permutations
- Permutations
- Permutations
- Permutations
- Permutations
- Permutations
- Permutations
- Permutations
- Permutations
- Permutations
- Permutations
- Permutations
- Permutations
- Permutations
- Permutations
- CentOS 64位 无法生成Core文件解决方法。
- Java Web笔记:JavaBean简介
- RabbitMQ消息队列的小伙伴: ProtoBuf(Google Protocol Buffer)
- php常用变量、常量积累
- 十进制与二进制的相互转换
- Permutations
- Ubuntu 14.04 下手动安装Firefox的Flash插件 32位
- DWZ局部刷新
- fedora install Chromium
- java 常用的日期操作
- php的一些函数
- 不同浏览器对与js处理时间的方式会有差异
- sql server 复制相关问题及解决方案
- jQuery.extend和jQuery.fn.extend的区别