Subsets
来源:互联网 发布:淘宝店铺会员制度 编辑:程序博客网 时间:2024/05/21 15:40
Given a set of distinct integers, S, return all possible subsets.
Note:
- Elements in a subset must be in non-descending order.
- The solution set must not contain duplicate subsets.
class Solution {public: void foo(vector<int> &S, int beginIdx, vector<int> &curVtr, vector<vector<int> > &retVtr) { retVtr.push_back(curVtr); for (int i=beginIdx; i<S.size(); i++) { curVtr.push_back(S[i]); foo(S, i+1, curVtr, retVtr); curVtr.pop_back(); } } vector<vector<int> > subsets(vector<int> &S) { vector<vector<int> > retVtr; vector<int> curVtr; sort(S.begin(), S.end()); int len = S.size(); foo(S, 0, curVtr, retVtr); return retVtr; }};
0 0
- Subsets
- Subsets
- Subsets
- Subsets
- Subsets
- Subsets
- Subsets
- Subsets
- Subsets
- Subsets
- Subsets
- Subsets
- Subsets
- Subsets
- Subsets
- Subsets
- Subsets
- Subsets
- 动态图表
- android中使用SurfaceView做视频播放器--视频切换无缝连接
- 重载和重写的区别
- Java中HashMap和TreeMap的区别深入理解
- js遍历table 和 jquery 遍历table
- Subsets
- jQuery页面下雪效果(支持IE7+,圣诞节专用
- 郑州非淋的治疗费用是多少
- [Accessibility] Missing contentDescription attribute on image
- 一个关于数组存储特定序列问题的思考
- Android 手机上获取物理唯一标识码
- OSChina 网站的 web.xml 文件
- 第十六周项目2-用指针玩字符串2
- Django 定义和使用模型