![](https://img-blog.csdnimg.cn/2019091813595558.png?x-oss-process=image/resize,m_fixed,h_224,w_224)
BFS & DFS
文章平均质量分 67
BFS和DFS搜索的知识与题目汇总
决定要好好毒树的Lucifer
这个作者很懒,什么都没留下…
展开
-
LeetCode 22 - 括号生成 (简单递归)
题目链接https://leetcode-cn.com/problems/generate-parentheses/submissions/题目:数字n代表生成括号的对数,请你设计一个函数,用于能够生成所有可能的并且有效的括号组合。Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.Example 1:Input: n = 3O...原创 2022-03-01 20:12:24 · 6683 阅读 · 0 评论 -
LeetCode 847 - 访问所有节点的最短路径
题目链接https://leetcode-cn.com/problems/shortest-path-visiting-all-nodes/题目:存在一个由 n 个节点组成的无向连通图,图中的节点按从 0 到 n - 1 编号。给你一个数组 graph 表示这个图。其中,graph[i] 是一个列表,由所有与节点 i 直接相连的节点组成。返回能够访问所有节点的最短路径的长度。你可以在任一节点开始和停止,也可以多次重访节点,并且可以重用边。You have an undirected, connect原创 2022-02-24 11:49:17 · 519 阅读 · 0 评论 -
LeetCode1631 - 最小体力消耗 (二分法BFS遍历、并查集)
题目:You are a hiker preparing for an upcoming hike. You are given heights, a 2D array of size rows x columns, where heights[row][col] represents the height of cell (row, col). You are situated(位于) in the top-left cell, (0, 0), and you hope to travel to th原创 2022-02-21 23:56:38 · 229 阅读 · 0 评论 -
LeetCode778 - 水位上升的泳池 (二分法BFS遍历、并查集)
题目:You are given an n x n integer matrix grid where each value grid[i][j] represents the elevation at that point (i, j).The rain starts to fall. At time t, the depth of the water everywhere is t. You can swim from a square to another 4-directionally ad原创 2022-02-15 18:14:26 · 226 阅读 · 0 评论