题库chevron_right分类chevron_right树状数组
label

树状数组

33 道题目
简单: 0中等: 8困难: 25

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

面试场景

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

常见误区

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

练习策略

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

推荐练习顺序

#题目难度
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.

中等
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…

中等
1409

查询带键的排列

This problem involves processing queries on a permutation using an array and binary indexed tree for efficient results.

中等
1505

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

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

困难
1649

通过指令创建有序数组

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

困难
1964

找出到每个位置为止最长的有效障碍赛跑路线

Compute the longest valid obstacle course at each position using binary search and careful array tracking techniques eff…

困难
2179

统计数组中好三元组数目

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

困难
2193

得到回文串的最少操作次数

The problem challenges you to find the minimum number of adjacent swaps to make a string a palindrome.

困难
2250

统计包含每个点的矩形数目

Given a set of rectangles and points, determine how many rectangles contain each point.

中等
2286

以组为单位订音乐会的门票

Design a ticketing system to allocate concert seats in specific groupings while efficiently handling seat reservations.

困难
2407

最长递增子序列 II

Determine the longest increasing subsequence in an array where consecutive elements differ by at most k using dynamic pr…

困难
2424

最长上传前缀

Calculate the longest continuous uploaded prefix in a video stream efficiently using a mix of binary search and data str…

中等
2426

满足不等式的数对数目

Count pairs in two arrays satisfying a given inequality condition using binary search over the valid answer space.

困难
2552

统计上升四元组

Given a permutation of numbers, count the number of increasing quadruplets using dynamic programming.

困难
2659

将数组清空

Solve the "Make Array Empty" problem using binary search to determine the minimum number of operations required.

困难
2736

最大和查询

Find the maximum sum of paired elements from two arrays under query constraints using efficient binary search techniques…

困难
2916

子数组不同元素数目的平方和 II

Compute the sum of squares of distinct elements in all subarrays using state transition dynamic programming efficiently.

困难
2926

平衡子序列的最大和

Learn to find the maximum sum of a balanced subsequence using dynamic programming and careful state transitions efficien…

困难
2940

找到 Alice 和 Bob 可以相遇的建筑

Determine the leftmost building where Alice and Bob can meet using a binary search over valid move sequences.

困难
3072

将元素分配到两个数组中 II

Distribute elements into two arrays based on conditions, utilizing a Binary Indexed Tree for efficient counting and simu…

困难
3161

物块放置查询

Determine if blocks can be placed on an infinite number line using queries, leveraging binary search over the valid answ…

困难
3187

数组中的峰值

Determine peaks in a dynamic integer array using efficient Binary Indexed Tree updates and range queries for fast result…

困难
3245

交替组 III

Solve Alternating Groups III using array manipulation and a binary indexed tree to track maximal alternating sequences e…

困难
3380

用点构造面积最大的矩形 I

Find the maximum area of a rectangle formed by given points on a plane with unique coordinates.

中等
3382

用点构造面积最大的矩形 II

Find the largest rectangle on a plane using given points while avoiding any interior points and optimizing with math and…

困难
3515

带权树中的最短路径

Solve the Shortest Path in a Weighted Tree using binary-tree traversal and efficient state tracking for queries.

困难

关联高频模式

LeetCode 树状数组题型题解:33题训练路线