当前位置:网站首页>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();
}
}
};
边栏推荐
猜你喜欢
经典文献阅读之--Deformable DETR
Lucene Basics
经典文献阅读之--SuMa++
神机百炼3.53-Kruskal
The official zero foundation introduction jetpack compose Chinese course is coming!
Current situation analysis of Devops and noops
Contest3147 - game 38 of 2021 Freshmen's personal training match_ A: chicken
CNN visualization technology -- detailed explanation of cam & grad cam and concise implementation of pytorch
线性dp(拆分篇)
Brain and cognitive neuroscience matlab psychoolbox cognitive science experimental design - experimental design 4
随机推荐
Contest3147 - game 38 of 2021 Freshmen's personal training match_ A: chicken
Google Go to sea entrepreneurship accelerator registration countdown 3 days, entrepreneurs pass through the guide in advance collection!
Lambda expressions and method references
格式校验js
CNN visualization technology -- detailed explanation of cam & grad cam and concise implementation of pytorch
Style modification of Mui bottom navigation
Go 学习笔记整合
On Web server
Generics and generic constraints of typescript
外部中断无法进入,删代码再还原就好......记录这个想不到的bug
Use some common functions of hbuilderx
Generic classes and parameterized classes of SystemVerilog
Detailed notes of ES6
Shenji Bailian 3.54-dichotomy of dyeing judgment
经典文献阅读之--SuMa++
Go learning notes integration
Leverage Google cloud infrastructure and landing area to build enterprise level cloud native excellent operation capability
Shenji Bailian 3.52-prim
memcached安装
让每一位开发者皆可使用机器学习技术