78. Subsets
来源:互联网 发布:淘宝注册店铺单能做吗 编辑:程序博客网 时间:2024/05/21 09:36
Given a set of distinct integers, nums, return all possible subsets.
Note:
- Elements in a subset must be in non-descending order.
- The solution set must not contain duplicate subsets.
For example,
If nums = [1,2,3]
, a solution is:
[ [3], [1], [2], [1,2,3], [1,3], [2,3], [1,2], []]
Subscribe to see which companies asked this question
public class Solution { void dfs(int [] number_array, int start, int number, List<Integer> array, List<List<Integer>> result) { if(number==array.size()) { result.add(new ArrayList<Integer>(array)); return; } for(int i=start;i<number_array.length;i++) { array.add(number_array[i]); dfs(number_array,i+1,number,array,result); array.remove(array.size()-1); } } public List<List<Integer>> subsets(int[] S) { List<List<Integer>> result = new ArrayList<List<Integer>>(); List<Integer> array = new ArrayList<Integer>(); result.add(array); if(S==null) { return result; } Arrays.sort(S); for(int i=1;i<=S.length;i++) { array.clear(); dfs(S,0,i,array,result); } return result; }}
0 0
- 78. Subsets
- 78. Subsets
- 78. Subsets
- 78. Subsets
- 78. Subsets
- 78. Subsets
- 78. Subsets
- 78. Subsets
- 78. Subsets
- 78. Subsets
- 78. Subsets
- 78. Subsets
- 78. Subsets
- 78. Subsets
- 78. Subsets
- 78. Subsets
- 78. Subsets
- 78. Subsets
- 如何通过IIS设置301重定向
- \\r \\r\\n \\t的区别,是什么意思
- Thinking in Java -- 类型信息
- 跨浏览器设计–你必须得了解的浏览器默认样式(User Agent Stylesheet)
- PHP不用数据库怎么弄图片分页
- 78. Subsets
- 直接恢复DEDE(织梦系统)网站备份数据
- MSN、腾讯QQ、SKYPE、阿里旺旺网页在线客服源代码
- 淘宝IP地址库API接口 (PHP)通过ip获取地址信息
- 用PHP对文件夹进行访问权限设置(文件防止被下载设置)
- setTimeout设置为0的作用
- 2015年05月28日
- 电脑的时钟相位怎样设置
- js 手机,pad,电脑,客户端判断跳转。。