题库chevron_right分类chevron_right线段树
segment

线段树

57 道题目
简单: 1中等: 11困难: 45

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

面试场景

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

常见误区

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

练习策略

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

推荐练习顺序

题库

线段树 题库

先展示一段最适合快速浏览的题目列表,继续滚动时再慢慢续载,避免专题页被长列表一下子拉穿。

慢加载专题题库

适合这类题很多的专题,先扫结构,再逐步深入。

hourglass_bottom滚动续载
search
tune难度

当前展示 24 / 57 道题目

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

天际线问题

The Skyline Problem requires calculating a city's silhouette using array manipulation and divide-and-conquer techniques …

困难
307

区域和检索 - 数组可修改

Implement a mutable range sum query using efficient design patterns to handle multiple updates and range sum queries.

中等
315

计算右侧小于当前元素的个数

Solve the Count of Smaller Numbers After Self problem using binary search and optimized algorithms.

困难
327

区间和的个数

Count the number of subarray sums within a given inclusive range using optimized divide-and-conquer techniques efficient…

困难
406

根据身高重建队列

Reconstruct a queue based on the given heights and the number of taller people in front, using sorting and binary indexe…

中等
493

翻转对

Count the number of reverse pairs in a given integer array using efficient algorithms like binary search and merge sort.

困难
673

最长递增子序列的个数

This problem challenges you to find the number of longest increasing subsequences in a given array of integers.

中等
699

掉落的方块

Solve Falling Squares by efficiently computing maximum stack heights using arrays with segment tree optimization techniq…

困难
715

Range 模块

Design a RangeModule to track and query half-open intervals using segment trees or ordered sets.

困难
729

我的日程安排表 I

Implement a calendar supporting non-overlapping event bookings using binary search for efficient insertion and conflict …

中等
731

我的日程安排表 II

Implement a calendar that allows double bookings but prevents triple bookings, managing overlapping intervals efficientl…

中等
732

我的日程安排表 III

Implement My Calendar III to track maximum overlapping events efficiently using binary search and segment tree technique…

困难
850

矩形面积 II

The problem involves calculating the total area covered by multiple rectangles, ensuring overlap is counted only once.

困难
1157

子数组中占绝大多数的元素

Efficiently find the majority element in any subarray using a data structure optimized for multiple range queries.

困难
1395

统计作战单位数

Count the number of valid three-soldier teams using ratings with a state transition dynamic programming approach efficie…

中等
1505

最多 K 次交换相邻数位后得到的最小整数

Reorder digits using at most k adjacent swaps to produce the smallest possible integer, leveraging greedy selection effi…

困难
1521

找到最接近目标值的函数值

In this problem, you'll use binary search to find the closest value of a mysterious function to a given target.

困难
1622

奇妙序列

Implement a Fancy sequence supporting append, addAll, and multAll operations efficiently using cumulative math design te…

困难
1649

通过指令创建有序数组

The problem asks to compute the cost of inserting elements into a sorted array using a series of instructions.

困难
1687

从仓库到码头运输箱子

Optimize the minimum number of trips to deliver boxes to ports under strict ship constraints using dynamic programming t…

困难
2080

区间内查询数字的频率

Design a data structure to handle efficient frequency queries for subarrays, focusing on hash-based lookups and efficien…

中等
2179

统计数组中好三元组数目

Count Good Triplets in an Array requires tracking index orders across two permutations efficiently using binary search.

困难
2213

由单个字符重复的最长子字符串

Solve Longest Substring of One Repeating Character by maintaining mergeable run information under character updates afte…

困难
2276

统计区间中的整数数目

Design and implement a data structure to efficiently add intervals and count the total number of integers covered by the…

困难

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

关联高频模式

LeetCode 线段树题型题解:57题训练路线