题库chevron_right分类chevron_right前缀和
data_array

前缀和

186 道题目
简单: 19中等: 113困难: 54

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

面试场景

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

常见误区

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

练习策略

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

推荐练习顺序

题库

前缀和 题库

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

慢加载专题题库

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

hourglass_bottom滚动续载
search
tune难度

当前展示 24 / 186 道题目

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

长度最小的子数组

Find the minimal length of a subarray whose sum is greater than or equal to the target using efficient algorithms.

中等
238

除了自身以外数组的乘积

Solve the 'Product of Array Except Self' problem by calculating the product of all elements except self for each index e…

中等
303

区域和检索 - 数组不可变

The Range Sum Query - Immutable problem involves implementing a data structure to handle range sum queries efficiently.

简单
304

二维区域和检索 - 矩阵不可变

Design a 2D matrix class that efficiently handles sum queries with O(1) time complexity using a prefix sum approach.

中等
363

矩形区域不超过 K 的最大数值和

Solve the "Max Sum of Rectangle No Larger Than K" problem using binary search over the valid sum space to optimize space…

困难
410

分割数组的最大值

Solve the 'Split Array Largest Sum' problem by minimizing the largest sum across k subarrays using dynamic programming a…

困难
497

非重叠矩形中的随机点

Design an algorithm to pick random points within non-overlapping rectangles using binary search and reservoir sampling.

中等
523

连续的子数组和

Identify if any continuous subarray sums to a multiple of k using prefix sums and hash table tracking efficiently.

中等
525

连续数组

Find the maximum length contiguous subarray with equal numbers of 0s and 1s using array scanning and hash lookup efficie…

中等
528

按权重随机选择

Random Pick with Weight requires implementing a probabilistic index picker using prefix sums and binary search efficient…

中等
560

和为 K 的子数组

Count the total number of contiguous subarrays in an integer array that sum exactly to a target value k using optimized …

中等
689

三个无重叠子数组的最大和

Maximize the sum of three non-overlapping subarrays with length k in an integer array using dynamic programming.

困难
713

乘积小于 K 的子数组

Count subarrays with a product strictly less than a given value k using efficient algorithms like binary search and slid…

中等
724

寻找数组的中心下标

Find the pivot index in an array where the sums of elements on both sides are equal using array and prefix sum technique…

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

困难
798

得分最高的最小轮调

Find the smallest rotation index with the highest score using array and prefix sum techniques.

困难
813

最大平均值和的分组

Maximize the sum of averages by partitioning an integer array into at most k contiguous subarrays using dynamic programm…

中等
848

字母移位

Given a string and a shift array, shift the first i+1 letters of the string as specified in the array.

中等
862

和至少为 K 的最短子数组

Find the shortest subarray with a sum of at least k using binary search and sliding window techniques.

困难
903

DI 序列的有效排列

The problem asks to find the number of valid permutations for a given DI sequence string using dynamic programming and s…

困难
930

和相同的二元子数组

Count all contiguous subarrays in a binary array whose elements sum exactly to a given goal using prefix sums efficientl…

中等
974

和可被 K 整除的子数组

Count the number of subarrays whose sum is divisible by a given integer k using array scanning and hash lookup.

中等
995

K 连续位的最小翻转次数

Determine the minimum number of k-length consecutive bit flips needed to convert all zeros to ones in a binary array eff…

困难

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

关联高频模式

LeetCode 前缀和题型题解:186题训练路线