题库chevron_right解题模式chevron_right二分·树·traversal
schema可复用解题模式

二分·树·traversal模式

模式页更适合建立可迁移的解题框架。先抓识别信号,再反复练状态定义、更新规则和边界解释,能比零散刷题更快形成稳定手感。

database161 道题tune38/88/35 难度梯度category6 个关联题型

模式摘要

先识别什么

题目里常出现可以复用的状态更新节奏。

解法节奏

先口述状态和不变量,再解释每一步如何更新,最后用反例验证边界。

高频失分点

状态定义说不清,写出来也难以稳定维护。

识别信号

  • 题目里常出现可以复用的状态更新节奏。
  • 暴力枚举太慢,但结构上存在可维护的不变量。
  • 面试追问通常会盯住边界、状态变更和复杂度。

解题流程

  1. 1. 明确窗口/状态定义
  2. 2. 更新状态并维护约束
  3. 3. 用边界样例验证

常见失分点

  • 状态定义说不清,写出来也难以稳定维护。
  • 只会背模板,解释不了为什么这样更新。
  • 样例能过,但边界和复杂度追问容易崩。

推荐题单梯度

题库

二分·树·traversal模式题库

这里更适合先按关键词或难度找题,再按关联题型切入。题库会在容器内继续滚动时慢慢续载,避免模式页被长列表一下子拉穿。

慢加载模式题库

适合先建模式理解,再扩展到完整题单。

hourglass_bottom容器内滚动续载
search
tune难度
category题型聚焦

当前展示 24 / 161 道题目

每次续载 24 题
#题目难度
94

二叉树的中序遍历

Binary Tree Inorder Traversal asks you to visit left subtree, node, then right subtree without losing position while mov…

简单
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…

中等
100

相同的树

Check whether two binary trees are identical by comparing structure and node values using DFS or BFS traversal strategie…

简单
101

对称二叉树

Determine if a binary tree is symmetric by comparing left and right subtrees using DFS or BFS traversal techniques effic…

简单
102

二叉树的层序遍历

Perform a level order traversal on a binary tree using BFS to return node values level by level.

中等
103

二叉树的锯齿形层序遍历

Traverse a binary tree in zigzag level order, alternating directions at each depth using BFS and state tracking techniqu…

中等
104

二叉树的最大深度

Find the maximum depth of a binary tree using traversal techniques to track the longest path from root to leaf.

简单
107

二叉树的层序遍历 II

Return a bottom-up level order traversal of a binary tree, processing nodes left to right while tracking each level accu…

中等
108

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

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

简单
110

平衡二叉树

Determine if a binary tree is height-balanced using tree traversal and state tracking techniques.

简单
111

二叉树的最小深度

Find the minimum depth of a binary tree, which is the shortest path from the root node to the nearest leaf node.

简单
112

路径总和

Determine if a binary tree has a root-to-leaf path where the sum of node values equals a given target sum, using DFS or …

简单
113

路径总和 II

Find all root-to-leaf paths in a binary tree where the sum of node values equals a given target using DFS backtracking.

中等
124

二叉树中的最大路径和

Calculate the maximum sum of any path in a binary tree by exploring all node sequences using DFS and dynamic programming…

困难
129

求根节点到叶节点数字之和

Calculate the sum of all root-to-leaf numbers in a binary tree where each path represents a number.

中等
144

二叉树的前序遍历

Perform a binary tree preorder traversal by visiting root nodes first, then left and right subtrees, tracking state iter…

简单
145

二叉树的后序遍历

Solve Binary Tree Postorder Traversal using state tracking and binary-tree traversal techniques, focusing on Stack, Tree…

简单
173

二叉搜索树迭代器

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

中等
199

二叉树的右视图

The Binary Tree Right Side View problem asks you to return the visible nodes from the right side of a binary tree, trave…

中等
222

完全二叉树的节点个数

Count Complete Tree Nodes efficiently by leveraging binary-tree traversal, exploiting completeness, and applying bit man…

简单
226

翻转二叉树

Invert Binary Tree swaps every node's left and right children using tree traversal, with recursive DFS or iterative BFS …

简单

swap_vert在题库框内继续向下滚动,也会自动续载

按题型继续深入

模式学会之后,最好回到具体题型里做迁移训练。这样更容易分清楚“模式本身”和“场景变化”分别在哪里。

route

引导式练习路径

AI 会按你的当前水平推荐题目,并持续记录练习进度。

开始引导练习arrow_forward
LeetCode 二分·树·traversal模式题解:161题训练路线