当前位置:网站首页>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();
}
}
};
边栏推荐
- Common websites for Postgraduates in data mining
- [C language] simple implementation of mine sweeping game
- 步骤详解 | 助您轻松提交 Google Play 数据安全表单
- LeetCode 40. 组合总和 II
- 格式校验js
- LeetCode 39. 组合总和
- Shenji Bailian 3.54-dichotomy of dyeing judgment
- Web page user step-by-step operation guide plug-in driver js
- 页面打印插件print.js
- Leverage Google cloud infrastructure and landing area to build enterprise level cloud native excellent operation capability
猜你喜欢

Mathematical statistics and machine learning

The official zero foundation introduction jetpack compose Chinese course is coming!

步骤详解 | 助您轻松提交 Google Play 数据安全表单

神机百炼3.52-Prim

keepalived安装使用与快速入门

Shenji Bailian 3.54-dichotomy of dyeing judgment

AttributeError: ‘str‘ object has no attribute ‘decode‘

Google Play Academy 组队 PK 赛,正式开赛!

Spark overview

借力 Google Cloud 基础设施和着陆区,构建企业级云原生卓越运营能力
随机推荐
网络相关知识(硬件工程师)
Use some common functions of hbuilderx
[C language] simple implementation of mine sweeping game
Contest3145 - the 37th game of 2021 freshman individual training match_ H: Eat fish
servlet的web.xml配置详解(3.0)
Talking about MySQL database
Go learning notes integration
Keepalived installation, use and quick start
Deep learning classification network -- vggnet
Contest3147 - game 38 of 2021 Freshmen's personal training match_ 1: Maximum palindromes
LeetCode 77. 组合
Current situation analysis of Devops and noops
memcached安装
如何使用MITMPROXy
Verifying downloaded files using sha256 files
51 single chip microcomputer - ADC explanation (a/d conversion, d/a conversion)
Redis key value database [advanced]
外部中断无法进入,删代码再还原就好......记录这个想不到的bug
WLAN相关知识点总结
Google Play Academy 组队 PK 赛,正式开赛!