![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Tree
文章平均质量分 67
透明蜗牛
这个作者很懒,什么都没留下…
展开
-
272. Closest Binary Search Tree Value II
272. Closest Binary Search Tree Value IIDescriptionIdeaCodebrute-forceDFSsearch on treeNotesDescriptionGiven the root of a binary search tree, a target value, and an integer k, return the k values in the BST that are closest to the target. You may return原创 2022-05-01 08:34:11 · 110 阅读 · 0 评论 -
98. Validate Binary Search Tree
98. Validate Binary Search TreeDescriptionIdeaCodecode 1code 2NotesDescriptionGiven the root of a binary tree, determine if it is a valid binary search tree (BST).A valid BST is defined as follows:The left subtree of a node contains only nodes with key原创 2022-04-27 14:17:49 · 528 阅读 · 0 评论 -
236. Lowest Common Ancestor of a Binary Tree
236. Lowest Common Ancestor of a Binary TreeDescriptionIdeaCodeNotesDescriptionGiven a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree.According to the definition of LCA on Wikipedia: “The lowest common ancestor is defi原创 2022-04-26 14:44:25 · 145 阅读 · 0 评论 -
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 评论 -
230. Kth Smallest Element in a BST
230. Kth Smallest Element in a BSTDescriptionThoughtsCodeinorder traversalstackDescriptionGiven the root of a binary search tree, and an integer k, return the kth smallest value (1-indexed) of all the values of the nodes in the tree.ThoughtsWe can simp原创 2022-04-14 14:33:13 · 91 阅读 · 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 评论 -
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 评论