Leetcode no. 78
来源:互联网 发布:看美股行情软件 编辑:程序博客网 时间:2024/06/06 09:45
78. Subsets
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], []]
public class Solution { public List<List<Integer>> subsets(int[] nums) { List<List<Integer>> list= new LinkedList<>(); if (nums.length==0) return list; Arrays.sort(nums); List<Integer> lzero= new LinkedList<>(); list.add(lzero); for (int i = 0; i < nums.length; i++) { List<List<Integer>> tmplist= new LinkedList<>(); for (List<Integer> ele: list) { List<Integer> it= new LinkedList<>(ele); it.add(nums[i]); tmplist.add(it); } list.addAll(tmplist); } return list; }}
0 0
- Leetcode NO.78 Subsets
- Leetcode no. 78
- Leetcode No.78 Subsets
- LeetCode No.78 Subsets
- LeetCode--No.78--Subsets
- LeetCode No.11 ~No.12
- Leetcode NO.77 Combinations
- Leetcode NO.46 Permutations
- 【leetcode】No. 235 LCABST
- LeetCode no. 35
- Leetcode no. 37
- Leetcode no. 279
- Leetcode no. 335
- Leetcode no. 283
- Leetcode no. 181 (sql)
- Leetcode no. 40
- Leetcode no. 238
- Leetcode no. 26
- BootStrap fileinput.js
- Linux系统负荷的概念 (load average)
- CircleProgressBar For Android(圆形进度条)
- python 编码小结
- iOS 证书更新,打包APP
- Leetcode no. 78
- Android中引起内存泄露的原因分析
- POJ 1904King's Quest 强连通分量 好题
- BZOJ 4515|SDOI 2016|游戏|树链剖分
- Codeforces 237B Young Table 【构造】
- 批量压缩解压
- [BZOJ2424][HAOI2010]订货(费用流)
- textField的键盘的处理 自定义键盘 自定义辅助工具条 UIDatePick的基本属性
- oracle中CAST函数使用简介 (