leetcode刷题,总结,记录,备忘78
来源:互联网 发布:微信支付 域名备案 编辑:程序博客网 时间:2024/06/05 15:30
leetcode78Subsets
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
class Solution {public: vector<int> temp; vector<vector<int> > result; void function(vector<int> & nums, int deep) { if (deep == nums.size()) { return; } for (int i = deep; i < nums.size(); ++i) { temp.push_back(nums[i]); result.push_back(temp); function(nums, i + 1); temp.pop_back(); } } vector<vector<int>> subsets(vector<int>& nums) { if (nums.size() == 0) { return result; } sort(nums.begin(), nums.end()); function(nums, 0); vector<int> t; result.push_back(t); return result; }};
0 0
- leetcode刷题,总结,记录,备忘78
- leetcode刷题。总结,记录,备忘 104
- leetcode刷题。总结,记录,备忘 100
- leetcode刷题。总结,记录,备忘 191
- leetcode刷题。总结,记录,备忘。168
- leetcode刷题, 总结,记录,备忘 171
- leetcode刷题 ,总结,记录,备忘。144
- leetcode刷题,总结,记录, 备忘 141
- leetcode刷题,总结,记录,备忘。116
- leetcode刷题,总结,记录,备忘。96
- leetcode刷题。记录,总结,备忘。217
- leetcode 刷题, 总结,记录,备忘 35
- leetcode刷题,总结,记录,备忘 226
- leetcode刷题,总结,记录,备忘 169
- leetcode刷题,总结,记录,备忘137
- leetcode刷题,总结,记录,备忘83
- leetcode刷题,总结,记录,备忘70
- leetcode刷题,总结,记录,备忘 108
- Android基础——自定义EditTExt实现去掉输入框添加下划线
- 从Samples中入门IOS开发(四)------ 基于socket的网络编程
- c++作业2——模拟ATM机
- leetcode——231—— Power of Two
- JAVA中使用commons-logging和log4j打印日志
- leetcode刷题,总结,记录,备忘78
- EasyDarwin流媒体云平台架构
- https通信加密过程
- leetcode 322. Coin Change-硬币交换|动态规划
- POJ 1470 Closest Common Ancestors【LCA Tarjan】
- 删除已经配置的类库和移除CocoaPods
- jinja2
- 从Samples中入门IOS开发(五)------ 基于HTTP的网络编程
- 收集的一些前辈高手的博客