Leetcode 230. Kth Smallest Element in a BST

Given a binary search tree, write a function kthSmallest to find the kth smallest element in it.求一个二叉搜索树的第k小值。题目链接:https://leetcode.com/problems/kth-s...

LeetCode 109. Convert Sorted List to BST

LeetCode 109. Convert Sorted List to BST

DescriptionGiven a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST.For this problem, a height-bal...

LeetCode 108. Convert Sorted Array to BST

LeetCode 108. Convert Sorted Array to BST

LeetCode 108. Convert Sorted Array to Binary Search TreeDescriptionGiven an array where elements are sorted in ascending order, convert it to a height...

【LeetCode538】把二叉搜索树转换为累加树(BST中序)

【LeetCode538】把二叉搜索树转换为累加树(BST中序)

1.题目2.思路一定注意有BST的条件,BST的特性是中序遍历(左中右)得到从小到大的序列,而题目求的是大于等于当前结点的值替换原值——注意这里是大于等于!!所以就不是单纯的中序,而是逆中序(右中左)。换句话说从题目的例子我们也能感性观察到左下方一坨的新值是比较大的&#x...

​LeetCode刷题实战333:最大 BST 子树

今天和大家聊的问题叫做 最大 BST 子树,我们先来看题面:https://leetcode-cn.com/problems/largest-bst-subtree/Given a binary tree, find the la...

[leetcode/lintcode 题解] 算法面试真题:BST的中序前驱节点

[leetcode/lintcode 题解] 算法面试真题:BST的中序前驱节点

描述给出一棵二叉搜索树以及其中的一个节点,找到这个节点在这棵树中的中序前驱节点。在线评测地址:领扣题库官网样例1 输入: root = {2,1,3}, p = 1 输出: null样例2 输入: root = {2,1}, p = 2 输出: 1用while循环模拟递归/** * Definiti...

[LeetCode] Largest BST Subtree 最大的二分搜索子树

Given a binary tree, find the largest subtree which is a Binary Search Tree (BST), where largest means subtree with largest number of nodes in it. Not...

[LeetCode] Inorder Successor in BST 二叉搜索树中的中序后继节点

Given a binary search tree and a node in it, find the in-order successor of that node in the BST. Note: If the given node has no in-order successor in...

[LeetCode] Serialize and Deserialize BST 二叉搜索树的序列化和去序列化

Serialization is the process of converting a data structure or object into a sequence of bits so that it can be stored in a file or memory buffer, or ...

[LeetCode] Delete Node in a BST 删除二叉搜索树中的节点

Given a root node reference of a BST and a key, delete the node with the given key in the BST. Return the root node reference (possibly updated) of th...

本页面内关键词为智能算法引擎基于机器学习所生成,如有任何问题,可在页面下方点击"联系我们"与我们沟通。

LeetCode bst相关内容