![](https://img-blog.csdnimg.cn/20201014180756926.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
BFS
文章平均质量分 71
透明蜗牛
这个作者很懒,什么都没留下…
展开
-
1586. Binary Search Tree Iterator II
1586. Binary Search Tree Iterator IIDescriptionIdeaCodeNotesDescriptionImplement the BSTIterator class that represents an iterator over the in-order traversal of a binary search tree (BST):BSTIterator(TreeNode root) Initializes an object of the BSTItera原创 2022-04-22 14:18:11 · 191 阅读 · 0 评论 -
Lintcode 573 · Build Post Office
Lintcode 573 · Build Post OfficeDescriptionNoteCodeDescriptionGiven a 2D grid, each cell is either a wall 2, an house 1 or empty 0 (the number zero, one, two), find a place to build a post office so that the sum of the distance from the post office to al原创 2022-03-21 13:33:58 · 64 阅读 · 0 评论 -
Connected Component in Undirected Graph
Connected Component in Undirected GraphDescriptionSimilar problemCodeDescriptionFind connected component in undirected graph.Each node in the graph contains a label and a list of its neighbors.(A connected component of an undirected graph is a subgraph原创 2022-03-10 15:27:25 · 132 阅读 · 0 评论 -
Graph Valid Tree
Graph Valid TreeDescriptionIdeaCodeDescriptionGiven n nodes labeled from 0 to n - 1 and a list of undirected edges (each edge is a pair of nodes), write a function to check whether these edges make up a valid tree.IdeaWe can simply use BFS but it’s imp原创 2022-03-10 14:58:47 · 368 阅读 · 0 评论 -
207. Course Schedule
207. Course ScheduleDescriptionThoughtsCodesNotesDescriptionThere are a total of numCourses courses you have to take, labeled from 0 to numCourses - 1. You are given an array prerequisites where prerequisites[i] = [ai, bi] indicates that you must take co原创 2022-02-16 14:03:41 · 130 阅读 · 0 评论 -
200. Number of Islands
200. Number of IslandsDescriptionAlgorithmExceptionsCodeTipsComplexityDescriptionGiven an m x n 2D binary grid grid which represents a map of '1’s (land) and '0’s (water), return the number of islands.An island is surrounded by water and is formed by co原创 2022-02-14 14:28:26 · 130 阅读 · 0 评论 -
102. Binary Tree Level Order Traversal
102. Binary Tree Level Order TraversalDescriptionExplainationCodesingle queue2 listsdummy nodeDescriptionGiven the root of a binary tree, return the level order traversal of its nodes’ values. (i.e., from left to right, level by level).ExplainationA cl原创 2022-02-02 14:56:54 · 309 阅读 · 0 评论