Subsets II
2016-07-10 20:48
239 查看
public class Solution { public List<List<Integer>> subsetsWithDup(int[] nums) { List<List<Integer>> res = new LinkedList<>(); if (nums == null || nums.length == 0) { return res; } List<Integer> list = new LinkedList<>(); Arrays.sort(nums); helper(res, list, nums, 0); return res; } private void helper(List<List<Integer>> res, List<Integer> list, int[] nums, int pos) { res.add(new LinkedList<>(list)); for (int i = pos; i < nums.length; i++) { if (i != pos && nums[i] == nums[i - 1]) { continue; } list.add(nums[i]); helper(res, list, nums, i + 1); list.remove(list.size() - 1); } } }
相关文章推荐
- 更新Ubuntu Kylin源遇到问题
- 0710学习记录
- Tomcat中内置DBCP数据库连接池使用
- redhat6.5搭建nginx+tomcat负载均衡,memcached高速缓存
- 继承
- 简单汇编反编译例子
- nyoj 275 队花的烦恼一
- 【NLP】揭秘马尔可夫模型神秘面纱系列文章(一)
- java 文件下载
- 新换的电脑,java 配置环境备忘下
- java面试宝典学习笔记(二)
- HDU 3029 Scales(三进制)
- sizeof与strlen傻傻分不清楚
- Node.js学习的第一步——环境配置
- 关于Bundle
- 过滤器
- C 语言泛型Array数组封装
- 嵌入式 Linux网络编程(一)——Socket网络编程基础
- JSP
- 读取hive文件并将数据导入hbase