随笔分类 -  DFS深度优先搜索算法

摘要:class Solution { public: vector<vector<int>> res; vector<int> path; int used[10]; void dfs(vector<int>& nums) { if (path.size() == nums.size()) { res. 阅读全文
posted @ 2022-09-05 14:57 hjy94wo 阅读(11) 评论(0) 推荐(0) 编辑
摘要:class Solution { public: vector<vector<int>> res; vector<int> path; bool used[10]; void dfs(vector<int>& nums) { if (path.size() == nums.size()) { res 阅读全文
posted @ 2022-09-05 14:44 hjy94wo 阅读(14) 评论(0) 推荐(0) 编辑
摘要:class Solution { public: vector<vector<int>> res; vector<int> path; int num = -101; void dfs(int start, vector<int>& nums) { if (path.size() > 1) { re 阅读全文
posted @ 2022-09-05 10:51 hjy94wo 阅读(5) 评论(0) 推荐(0) 编辑
摘要:class Solution { public: vector<vector<int>> res; vector<int> path; void dfs(int start, vector<int>& nums) { res.push_back(path); for (int i = start; 阅读全文
posted @ 2022-09-05 10:07 hjy94wo 阅读(10) 评论(0) 推荐(0) 编辑
摘要:class Solution { public: vector<vector<int>> res; vector<int> path; void dfs(int start, vector<int>& nums) { res.push_back(path); for (int i = start; 阅读全文
posted @ 2022-09-05 08:45 hjy94wo 阅读(13) 评论(0) 推荐(0) 编辑
摘要:class Solution { public: vector<string> res; int pointNum; bool isValid(string s, int begin, int end) { if (begin > end) return false; //防止在最后末尾插入. if 阅读全文
posted @ 2022-09-04 15:54 hjy94wo 阅读(23) 评论(0) 推荐(0) 编辑
摘要:class Solution { public: vector<vector<string>> res; vector<string> path; bool is(string s, int start, int end) { for (int i = start, j = end; i < j; 阅读全文
posted @ 2022-09-04 15:00 hjy94wo 阅读(13) 评论(0) 推荐(0) 编辑
摘要:class Solution { public: vector<vector<int>> res; vector<int> path; int sum = 0; void dfs(int start, int k, int n) { if (path.size() > k || sum > n) r 阅读全文
posted @ 2022-09-04 14:34 hjy94wo 阅读(8) 评论(0) 推荐(0) 编辑
摘要:class Solution { public: vector<vector<int>> res; vector<int> path; int sum; void dfs(int start, vector<int>& candidates, int target) { if (sum > targ 阅读全文
posted @ 2022-09-04 09:18 hjy94wo 阅读(22) 评论(0) 推荐(0) 编辑
摘要:class Solution { public: vector<vector<int>> res; vector<int> path; int sum = 0; void dfs(int start, vector<int>& candidates, int target) { if (sum > 阅读全文
posted @ 2022-09-04 08:51 hjy94wo 阅读(11) 评论(0) 推荐(0) 编辑
摘要:dfs 定义string数组初始化后加; char型 - ‘0’转为int型 class Solution { public: vector<string> res; string path; const string map[10] = { "", "", "abc", "def", "ghi", 阅读全文
posted @ 2022-09-02 16:37 hjy94wo 阅读(16) 评论(0) 推荐(0) 编辑
摘要:dfs class Solution { public: vector<int> path; vector<vector<int>> res; void dfs(int start, int n, int k) { if (path.size() == k) { res.push_back(path 阅读全文
posted @ 2022-09-02 16:11 hjy94wo 阅读(11) 评论(0) 推荐(0) 编辑
摘要:const int N = 20; class Solution { public: vector<vector<string>> res; bool col[N], dg[N], udg[N]; void dfs(int u, int n, vector<string>& path) { if ( 阅读全文
posted @ 2022-09-02 15:29 hjy94wo 阅读(12) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示