Leetcode-cn.com 2022-03-21
🟢 653.two-sum-iv-input-is-a-bst
🏷️ Tags
#tree #depth_first_search #breadth_first_search #binary_search_tree #hash_table #two_pointers #binary_tree
Description
给定一个二叉搜索树
Example
🟢 653.two-sum-iv-input-is-a-bst
🏷️ Tags
#tree #depth_first_search #breadth_first_search #binary_search_tree #hash_table #two_pointers #binary_tree
Description
给定一个二叉搜索树
root 和一个目标结果 k,如果 BST 中存在两个元素且它们的和等于给定的目标结果,则返回 true。Example
输入: root = [5,3,6,2,4,null,7], k = 9
输出: true
Leetcode-cn.com 2022-05-01
🟡 1305.all-elements-in-two-binary-search-trees
🏷️ Tags
#tree #depth_first_search #binary_search_tree #binary_tree #sorting
Description
给你
Example
🟡 1305.all-elements-in-two-binary-search-trees
🏷️ Tags
#tree #depth_first_search #binary_search_tree #binary_tree #sorting
Description
给你
root1 和 root2 这两棵二叉搜索树。请你返回一个列表,其中包含 两棵树 中的所有整数并按 升序 排序。.Example
输入:root1 = [2,1,4], root2 = [1,0,3]
输出:[0,1,1,2,3,4]
Leetcode-cn.com 2022-05-11
🟡 449.serialize-and-deserialize-bst
🏷️ Tags
#tree #depth_first_search #breadth_first_search #design #binary_search_tree #string #binary_tree
Description
序列化是将数据结构或对象转换为一系列位的过程,以便它可以存储在文件或内存缓冲区中,或通过网络连接链路传输,以便稍后在同一个或另一个计算机环境中重建。
设计一个算法来序列化和反序列化 二叉搜索树 。 对序列化/反序列化算法的工作方式没有限制。 您只需确保二叉搜索树可以序列化为字符串,并且可以将该字符串反序列化为最初的二叉搜索树。
编码的字符串应尽可能紧凑。
Example
🟡 449.serialize-and-deserialize-bst
🏷️ Tags
#tree #depth_first_search #breadth_first_search #design #binary_search_tree #string #binary_tree
Description
序列化是将数据结构或对象转换为一系列位的过程,以便它可以存储在文件或内存缓冲区中,或通过网络连接链路传输,以便稍后在同一个或另一个计算机环境中重建。
设计一个算法来序列化和反序列化 二叉搜索树 。 对序列化/反序列化算法的工作方式没有限制。 您只需确保二叉搜索树可以序列化为字符串,并且可以将该字符串反序列化为最初的二叉搜索树。
编码的字符串应尽可能紧凑。
Example
输入:root = [2,1,3]
输出:[2,1,3]
Leetcode-cn.com 2022-05-16
🟡 面试题 04.06.successor-lcci
🏷️ Tags
#tree #depth_first_search #binary_search_tree #binary_tree
Description
设计一个算法,找出二叉搜索树中指定节点的“下一个”节点(也即中序后继)。
如果指定节点没有对应的“下一个”节点,则返回
Example
🟡 面试题 04.06.successor-lcci
🏷️ Tags
#tree #depth_first_search #binary_search_tree #binary_tree
Description
设计一个算法,找出二叉搜索树中指定节点的“下一个”节点(也即中序后继)。
如果指定节点没有对应的“下一个”节点,则返回
null。Example
输入: root = [2,1,3], p = 1
2
/ \
1 3
输出: 2
Leetcode-cn.com 2022-06-02
🟡 450.delete-node-in-a-bst
🏷️ Tags
#tree #binary_search_tree #binary_tree
Description
给定一个二叉搜索树的根节点 root 和一个值 key,删除二叉搜索树中的 key 对应的节点,并保证二叉搜索树的性质不变。返回二叉搜索树(有可能被更新)的根节点的引用。
一般来说,删除节点可分为两个步骤:
首先找到需要删除的节点;
如果找到了,删除它。
Example
🟡 450.delete-node-in-a-bst
🏷️ Tags
#tree #binary_search_tree #binary_tree
Description
给定一个二叉搜索树的根节点 root 和一个值 key,删除二叉搜索树中的 key 对应的节点,并保证二叉搜索树的性质不变。返回二叉搜索树(有可能被更新)的根节点的引用。
一般来说,删除节点可分为两个步骤:
首先找到需要删除的节点;
如果找到了,删除它。
Example
输入:root = [5,3,6,2,4,null,7], key = 3
输出:[5,4,6,2,null,null,7]
解释:给定需要删除的节点值是 3,所以我们首先找到 3 这个节点,然后删除它。
一个正确的答案是 [5,4,6,2,null,null,7], 如下图所示。
另一个正确答案是 [5,2,6,null,4,null,7]。
108.convert-sorted-array-to-binary-search-tree.pdf
103.1 KB
leetcode.com 2022-08-10
🟢108.convert-sorted-array-to-binary-search-tree
🏷️ Tags
#array #divide_and_conquer #tree #binary_search_tree #binary_tree
🟢108.convert-sorted-array-to-binary-search-tree
🏷️ Tags
#array #divide_and_conquer #tree #binary_search_tree #binary_tree
98.validate-binary-search-tree.pdf
87.7 KB
leetcode.com 2022-08-11
🟡98.validate-binary-search-tree
🏷️ Tags
#tree #depth_first_search #binary_search_tree #binary_tree
🟡98.validate-binary-search-tree
🏷️ Tags
#tree #depth_first_search #binary_search_tree #binary_tree
235.lowest-common-ancestor-of-a-binary-search-tree.pdf
66.9 KB
leetcode.com 2022-08-12
🟢235.lowest-common-ancestor-of-a-binary-search-tree
🏷️ Tags
#tree #depth_first_search #binary_search_tree #binary_tree
🟢235.lowest-common-ancestor-of-a-binary-search-tree
🏷️ Tags
#tree #depth_first_search #binary_search_tree #binary_tree
669.trim-a-binary-search-tree.pdf
114.5 KB
leetcode.cn 2022-09-10
🟡669.trim-a-binary-search-tree
🏷️ Tags
#tree #depth_first_search #binary_search_tree #binary_tree
🟡669.trim-a-binary-search-tree
🏷️ Tags
#tree #depth_first_search #binary_search_tree #binary_tree
653.two-sum-iv-input-is-a-bst.pdf
109.5 KB
leetcode.com 2022-10-09
🟢653.two-sum-iv-input-is-a-bst
🏷️ Tags
#hash_table #two_pointers #tree #depth_first_search #breadth_first_search #binary_search_tree #binary_tree
🟢653.two-sum-iv-input-is-a-bst
🏷️ Tags
#hash_table #two_pointers #tree #depth_first_search #breadth_first_search #binary_search_tree #binary_tree
938.range-sum-of-bst.pdf
110.9 KB
leetcode.com 2022-12-07
🟢938.range-sum-of-bst
🏷️ Tags
#tree #depth_first_search #binary_search_tree #binary_tree
🟢938.range-sum-of-bst
🏷️ Tags
#tree #depth_first_search #binary_search_tree #binary_tree
783.minimum-distance-between-bst-nodes.pdf
86.4 KB
leetcode.com 2023-02-17
🟢783.minimum-distance-between-bst-nodes
🏷️ Tags
#tree #depth_first_search #breadth_first_search #binary_search_tree #binary_tree
🟢783.minimum-distance-between-bst-nodes
🏷️ Tags
#tree #depth_first_search #breadth_first_search #binary_search_tree #binary_tree
109.convert-sorted-list-to-binary-search-tree.pdf
106.1 KB
leetcode.com 2023-03-11
🟡109.convert-sorted-list-to-binary-search-tree
🏷️ Tags
#linked_list #divide_and_conquer #tree #binary_search_tree #binary_tree
🟡109.convert-sorted-list-to-binary-search-tree
🏷️ Tags
#linked_list #divide_and_conquer #tree #binary_search_tree #binary_tree
leetcode.cn 2023-05-20
🔴1373.maximum-sum-bst-in-binary-tree
🏷️ Tags
#tree #depth_first_search #binary_search_tree #dynamic_programming #binary_tree
🔴1373.maximum-sum-bst-in-binary-tree
🏷️ Tags
#tree #depth_first_search #binary_search_tree #dynamic_programming #binary_tree
Telegraph
maximum-sum-bst-in-binary-tree
给你一棵以 root 为根的 二叉树 ,请你返回 任意 二叉搜索子树的最大键值和。 二叉搜索树的定义如下:
leetcode.com 2023-05-23
🟢703.kth-largest-element-in-a-stream
🏷️ Tags
#tree #design #binary_search_tree #binary_tree #data_stream #heap_priority_queue
🟢703.kth-largest-element-in-a-stream
🏷️ Tags
#tree #design #binary_search_tree #binary_tree #data_stream #heap_priority_queue
Telegraph
kth-largest-element-in-a-stream
Design a class to find the kth largest element in a stream. Note that it is the kth largest element in the sorted order, not the kth distinct element. Implement KthLargest class: