面试场景
高频考察问题建模、边界条件与口头表达的清晰度。
常见误区
只背模板不解释为什么,容易在追问里失分。
练习策略
每轮练 3-5 题,固定复盘复杂度和可替代解法。
推荐练习顺序
不同的二叉搜索树 II
Generate all structurally unique BSTs with values 1 to n using backtracking and recursive tree construction techniques.
不同的二叉搜索树
Given n nodes, calculate the number of unique binary search trees (BSTs) that can be formed with values from 1 to n.
验证二叉搜索树
Validate Binary Search Tree problem checks if a binary tree satisfies BST properties using tree traversal and state trac…
恢复二叉搜索树
Recover a BST where two nodes are swapped by mistake using in-order traversal and careful state tracking to restore corr…
将有序数组转换为二叉搜索树
Pick the middle element as root at each step so the sorted array becomes a height-balanced BST with valid ordering.
有序链表转换二叉搜索树
Convert a sorted singly linked list into a height-balanced BST using pointer manipulation and divide-and-conquer recursi…
二叉搜索树迭代器
Implement an iterator for in-order traversal of a binary search tree (BST), maintaining traversal state with stack-based…
二叉搜索树中第 K 小的元素
Find the kth smallest element in a BST by leveraging in-order traversal to efficiently track node order and count.
二叉搜索树的最近公共祖先
Find the lowest common ancestor (LCA) of two nodes in a binary search tree, using binary-tree traversal and state tracki…
序列化和反序列化二叉搜索树
Design an algorithm to serialize and deserialize a binary search tree with efficient traversal and state tracking.
删除二叉搜索树中的节点
Delete Node in a BST hinges on removing one target while preserving in-order ordering through carefully chosen subtree r…
二叉搜索树中的众数
Find Mode in Binary Search Tree asks to identify the most frequent element(s) in a BST using binary-tree traversal.
二叉搜索树的最小绝对差
Find the minimum absolute difference between values of any two nodes in a BST using tree traversal and careful state tra…
把二叉搜索树转换为累加树
Convert a BST into a Greater Tree by updating each node’s value with the sum of all greater values in the tree.
两数之和 IV - 输入二叉搜索树
Determine if a binary search tree contains two nodes whose values sum to a target using efficient traversal and state tr…
修剪二叉搜索树
Trim a Binary Search Tree by maintaining its structure while removing nodes outside a given range.
二叉搜索树中的搜索
Locate a target value in a binary search tree and return the subtree rooted at that node using efficient tree traversal …
二叉搜索树中的插入操作
Insert a value into a Binary Search Tree while maintaining the BST properties, focusing on tree traversal and state trac…
数据流中的第 K 大元素
Find the kth largest element in a dynamic stream using binary-tree traversal and efficient state tracking with a min-hea…
二叉搜索树节点最小距离
Find the minimum difference between values of two different nodes in a Binary Search Tree using tree traversal and state…
递增顺序搜索树
Rearrange a binary search tree so all nodes follow increasing order with only right children using in-order traversal.
二叉搜索树的范围和
Given a BST and a range, calculate the sum of all node values within that range.
前序遍历构造二叉搜索树
Construct a binary search tree directly from a preorder traversal array using stack-based state tracking efficiently.
从二叉搜索树到更大和树
Convert a Binary Search Tree to a Greater Sum Tree by accumulating all larger node values using reverse in-order travers…
两棵二叉搜索树中的所有元素
Merge elements from two binary search trees and return them sorted in ascending order.
二叉搜索子树的最大键值和
Find the maximum sum of values from any Binary Search Tree (BST) subtree in a binary tree.
将二叉搜索树变平衡
This problem requires balancing a binary search tree using in-order traversal and state tracking techniques.
将子数组重新排序得到同一个二叉搜索树的方案数
Determine the number of ways to reorder an array to get the same binary search tree (BST) from its insertion order.
二叉搜索树最近节点查询
Solve the problem of finding closest nodes in a Binary Search Tree for multiple queries, efficiently handling each query…