![](https://img-blog.csdnimg.cn/20190918140145169.png?x-oss-process=image/resize,m_fixed,h_224,w_224)
DFS
深度优先搜索
CervoLu
这个作者很懒,什么都没留下…
展开
-
104二叉树的深度
二叉树的深度用深度优先搜索可以很快的写出来 #include<iostream> #include<queue> #include<vector> using namespace std; struct TreeNode { int val; TreeNode *left; TreeNode *right; TreeNode() : val(0), left(nullptr), right(nullptr) {} TreeNode(原创 2021-11-24 22:51:52 · 168 阅读 · 1 评论 -
17电话号码的字母组合
看到所有组合就应该明白这题考察了搜索算法,可以使用DFS或者BFS 数字对应字母用了一个哈希表实现,主体部分看了题解,自己加了点注释,主要之前没怎么用过DFS。 #include<iostream> #include<vector> #include<unordered_map> using namespace std; class Solution { public: vector<string> letterCombinations(string原创 2021-11-17 11:18:31 · 65 阅读 · 0 评论