题库chevron_right分类chevron_right二叉搜索树
search

二叉搜索树

29 道题目
简单: 9中等: 18困难: 2

二叉搜索树 是技术面试里最常出现的能力维度之一。建议先掌握基础题型的边界处理,再逐步过渡到模式识别和复杂度 trade-off。

面试场景

高频考察问题建模、边界条件与口头表达的清晰度。

常见误区

只背模板不解释为什么,容易在追问里失分。

练习策略

每轮练 3-5 题,固定复盘复杂度和可替代解法。

推荐练习顺序

#题目难度
95

不同的二叉搜索树 II

Generate all structurally unique BSTs with values 1 to n using backtracking and recursive tree construction techniques.

中等
96

不同的二叉搜索树

Given n nodes, calculate the number of unique binary search trees (BSTs) that can be formed with values from 1 to n.

中等
98

验证二叉搜索树

Validate Binary Search Tree problem checks if a binary tree satisfies BST properties using tree traversal and state trac…

中等
99

恢复二叉搜索树

Recover a BST where two nodes are swapped by mistake using in-order traversal and careful state tracking to restore corr…

中等
108

将有序数组转换为二叉搜索树

Pick the middle element as root at each step so the sorted array becomes a height-balanced BST with valid ordering.

简单
109

有序链表转换二叉搜索树

Convert a sorted singly linked list into a height-balanced BST using pointer manipulation and divide-and-conquer recursi…

中等
173

二叉搜索树迭代器

Implement an iterator for in-order traversal of a binary search tree (BST), maintaining traversal state with stack-based…

中等
230

二叉搜索树中第 K 小的元素

Find the kth smallest element in a BST by leveraging in-order traversal to efficiently track node order and count.

中等
235

二叉搜索树的最近公共祖先

Find the lowest common ancestor (LCA) of two nodes in a binary search tree, using binary-tree traversal and state tracki…

中等
449

序列化和反序列化二叉搜索树

Design an algorithm to serialize and deserialize a binary search tree with efficient traversal and state tracking.

中等
450

删除二叉搜索树中的节点

Delete Node in a BST hinges on removing one target while preserving in-order ordering through carefully chosen subtree r…

中等
501

二叉搜索树中的众数

Find Mode in Binary Search Tree asks to identify the most frequent element(s) in a BST using binary-tree traversal.

简单
530

二叉搜索树的最小绝对差

Find the minimum absolute difference between values of any two nodes in a BST using tree traversal and careful state tra…

简单
538

把二叉搜索树转换为累加树

Convert a BST into a Greater Tree by updating each node’s value with the sum of all greater values in the tree.

中等
653

两数之和 IV - 输入二叉搜索树

Determine if a binary search tree contains two nodes whose values sum to a target using efficient traversal and state tr…

简单
669

修剪二叉搜索树

Trim a Binary Search Tree by maintaining its structure while removing nodes outside a given range.

中等
700

二叉搜索树中的搜索

Locate a target value in a binary search tree and return the subtree rooted at that node using efficient tree traversal …

简单
701

二叉搜索树中的插入操作

Insert a value into a Binary Search Tree while maintaining the BST properties, focusing on tree traversal and state trac…

中等
703

数据流中的第 K 大元素

Find the kth largest element in a dynamic stream using binary-tree traversal and efficient state tracking with a min-hea…

简单
783

二叉搜索树节点最小距离

Find the minimum difference between values of two different nodes in a Binary Search Tree using tree traversal and state…

简单
897

递增顺序搜索树

Rearrange a binary search tree so all nodes follow increasing order with only right children using in-order traversal.

简单
938

二叉搜索树的范围和

Given a BST and a range, calculate the sum of all node values within that range.

简单
1008

前序遍历构造二叉搜索树

Construct a binary search tree directly from a preorder traversal array using stack-based state tracking efficiently.

中等
1038

从二叉搜索树到更大和树

Convert a Binary Search Tree to a Greater Sum Tree by accumulating all larger node values using reverse in-order travers…

中等
1305

两棵二叉搜索树中的所有元素

Merge elements from two binary search trees and return them sorted in ascending order.

中等
1373

二叉搜索子树的最大键值和

Find the maximum sum of values from any Binary Search Tree (BST) subtree in a binary tree.

困难
1382

将二叉搜索树变平衡

This problem requires balancing a binary search tree using in-order traversal and state tracking techniques.

中等
1569

将子数组重新排序得到同一个二叉搜索树的方案数

Determine the number of ways to reorder an array to get the same binary search tree (BST) from its insertion order.

困难
2476

二叉搜索树最近节点查询

Solve the problem of finding closest nodes in a Binary Search Tree for multiple queries, efficiently handling each query…

中等

关联高频模式

LeetCode 二叉搜索树题型题解:29题训练路线