当前位置:网站首页>LeetCode 78. subset
LeetCode 78. subset
2022-07-02 06:11:00 【Great white sheep_ Aries】
Title Description
solution
The permutation and combination problems involved in programming are inseparable from backtracking , Below we post a pseudo code about backtracking , With this backtracking framework , Combined with the backtracking tree, it is easy to understand
result = []
def backtrack( route , Selection list ):
if Meet the end condition :
result.add( route )
return
for choice in Selection list :
To make a choice
backtrack( route , Selection list )
Unselect

class Solution {
public:
vector<vector<int>> res;
vector<vector<int>> subsets(vector<int>& nums) {
vector<int> track;
backtrace(nums, 0, track);
return res;
}
void backtrace(vector<int>& nums, int start, vector<int>& track){
res.push_back(track);
for (int i = start; i < nums.size(); i++)
{
track.push_back(nums[i]);
backtrace(nums, i + 1, track);
track.pop_back();
}
}
};
边栏推荐
- Google Play Academy 组队 PK 赛,正式开赛!
- Keepalived installation, use and quick start
- Ti millimeter wave radar learning (I)
- Spark overview
- Contest3147 - game 38 of 2021 Freshmen's personal training match_ G: Flower bed
- STC8H8K系列匯編和C51實戰——數碼管顯示ADC、按鍵串口回複按鍵號與ADC數值
- 亚马逊aws数据湖工作之坑1
- Deep learning classification network -- alexnet
- AttributeError: ‘str‘ object has no attribute ‘decode‘
- Contest3145 - the 37th game of 2021 freshman individual training match_ H: Eat fish
猜你喜欢

Deep learning classification network -- vggnet

Little bear sect manual query and ADC in-depth study

BGP报文详细解释

Google Go to sea entrepreneurship accelerator registration countdown 3 days, entrepreneurs pass through the guide in advance collection!

Shenji Bailian 3.53-kruskal

uni-app开发中遇到的问题(持续更新)

脑与认知神经科学Matlab Psytoolbox认知科学实验设计——实验设计四

From design delivery to development, easy and efficient!

Frequently asked questions about jetpack compose and material you

Shenji Bailian 3.54-dichotomy of dyeing judgment
随机推荐
On Web server
Ti millimeter wave radar learning (I)
keepalived安装使用与快速入门
Classic literature reading -- deformable Detr
Current situation analysis of Devops and noops
MySQL transaction and isolation level
格式校验js
Summary of MySQL constraints
Community theory | kotlin flow's principle and design philosophy
uni-app开发中遇到的问题(持续更新)
Deep learning classification network -- alexnet
Database learning summary 5
ZABBIX server trap command injection vulnerability (cve-2017-2824)
Keepalived installation, use and quick start
Shenji Bailian 3.53-kruskal
LeetCode 283. 移动零
图片裁剪插件cropper.js
Web components series (VIII) -- custom component style settings
LeetCode 78. 子集
How vite is compatible with lower version browsers