题库chevron_right解题模式chevron_right前缀和
schema可复用解题模式

前缀和模式

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

database37 道题tune11/22/4 难度梯度category6 个关联题型

模式摘要

先识别什么

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

解法节奏

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

高频失分点

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

识别信号

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

解题流程

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

常见失分点

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

推荐题单梯度

题库

前缀和模式题库

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

慢加载模式题库

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

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

当前展示 24 / 37 道题目

每次续载 24 题
#题目难度
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.

中等
724

寻找数组的中心下标

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

简单
798

得分最高的最小轮调

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

困难
1109

航班预订统计

Solve Corporate Flight Bookings by marking range changes once, then building final seat totals with a single prefix sum …

中等
1310

子数组异或查询

Compute XOR results for multiple subarray queries using efficient prefix XOR to reduce repeated computation overhead in …

中等
1371

每个元音包含偶数次的最长子字符串

Find the longest substring with even counts of vowels using bitmasking and hash tables.

中等
1413

逐步求和得到正数的最小值

Find the minimum starting value to ensure the step-by-step sum of an array is always at least 1.

简单
1422

分割字符串的最大得分

Find the optimal split point in a binary string to maximize zeros on the left and ones on the right efficiently.

简单
1480

一维数组的动态和

Calculate the running sum of a given 1D array by updating each element to the sum of itself and all previous elements.

简单
1664

生成平衡数组的方案数

Solve Ways to Make a Fair Array by tracking parity sums before and after each removal with prefix-sum style accounting.

中等
1732

找到最高海拔

Find the highest altitude after a series of altitude changes during a road trip using prefix sum technique.

简单
1737

满足三条件之一需改变的最少字符数

This problem asks for the minimum operations to change two strings so that one of three conditions is met.

中等
1744

你能在你最喜欢的那天吃到你最喜欢的糖果吗?

Determine if you can eat a candy of your favorite type on a specific day, given daily limits and candy availability.

中等
1829

每个查询的最大异或值

Find the maximum XOR for each query based on a sorted array and bit manipulation.

中等
1854

人口最多的年份

Find the earliest year with the highest population using an array plus counting approach.

简单
1915

最美子字符串的数目

Count the number of wonderful non-empty substrings of a given string based on frequency conditions of characters.

中等
1930

长度为 3 的不同回文子序列

Count all unique length-3 palindromic subsequences in a string efficiently using hash tables and character positions.

中等
1991

找到数组的中间位置

Find the smallest middle index where the sum of elements on the left equals the sum on the right using prefix sums effic…

简单
2145

统计隐藏数组数目

Given a sequence of differences, count how many hidden sequences fit within a range using an array and prefix sum approa…

中等
2256

最小平均差

Find the index with the minimum average difference in an array using prefix sums.

中等
2270

分割数组的方案数

Count all valid ways to split a 0-indexed integer array into two non-empty parts using array plus prefix sum logic effic…

中等
2438

二的幂数组中查询范围内的乘积

The Range Product Queries of Powers problem requires calculating the product of powers of 2 for a range of queries on a …

中等

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

按题型继续深入

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

route

引导式练习路径

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

开始引导练习arrow_forward
LeetCode 前缀和模式题解:37题训练路线