题库chevron_right解题模式chevron_right滑动窗口(状态滚动更新)
view_carousel可复用解题模式

滑动窗口(状态滚动更新)模式

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

database66 道题tune14/37/15 难度梯度category6 个关联题型

模式摘要

先识别什么

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

解法节奏

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

高频失分点

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

识别信号

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

解题流程

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

常见失分点

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

推荐题单梯度

题库

滑动窗口(状态滚动更新)模式题库

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

慢加载模式题库

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

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

当前展示 24 / 66 道题目

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

无重复字符的最长子串

Find the length of the longest substring without repeating characters using a sliding window and hash map to track state…

中等
30

串联所有单词的子串

Find all starting indices of substrings in a string that are concatenations of a given list of words.

困难
76

最小覆盖子串

Find the smallest substring of s containing all characters from t using a sliding window with running state updates for …

困难
187

重复的DNA序列

Solve Repeated DNA Sequences by sliding a length-10 window and tracking seen patterns with a hash set or bitmask.

中等
220

存在重复元素 III

The problem involves finding a pair of indices in an array where the index and value differences are within given limits…

困难
239

滑动窗口最大值

Solve the "Sliding Window Maximum" problem using efficient techniques like the sliding window, deque, and priority queue…

困难
395

至少有 K 个重复字符的最长子串

Find the length of the longest substring where every character appears at least k times using sliding window and divide-…

中等
424

替换后的最长重复字符

Find the length of the longest substring after at most k replacements using a sliding window and character count trackin…

中等
438

找到字符串中所有字母异位词

Find all starting indices of p's anagrams in s using sliding window and hash table approach.

中等
643

子数组最大平均数 I

Find the maximum average of any contiguous subarray of length k in a given integer array using a sliding window approach…

简单
995

K 连续位的最小翻转次数

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

困难
1016

子串能表示从 1 到 N 数字的二进制串

Check if binary string contains all integers from 1 to n as substrings, leveraging sliding window and bit manipulation t…

中等
1040

移动石子直到连续 II

Determine the minimum and maximum moves to make stones consecutive using sliding window and endpoint adjustments efficie…

中等
1052

爱生气的书店老板

Maximize satisfied customers in a bookstore by strategically suppressing the owner's grumpy minutes using a sliding wind…

中等
1156

单字符重复子串的最大长度

Find the maximum length of a repeated character substring after swapping two characters using a sliding window approach …

中等
1234

替换子串得到平衡字符串

Determine the minimum substring length to replace in order to balance a string of Q, W, E, and R characters efficiently.

中等
1297

子串的最大出现次数

Find the maximum number of occurrences of any valid substring in a given string with specific constraints on letter coun…

中等
1343

大小为 K 且平均值大于等于阈值的子数组数目

Given an array, find the number of sub-arrays of size k with an average greater than or equal to a given threshold.

中等
1358

包含所有三种字符的子字符串数目

Count all substrings containing at least one of each character a, b, and c using a sliding window approach efficiently.

中等
1423

可获得的最大点数

Maximize your score by selecting k cards from the beginning or end of the array using a sliding window approach.

中等
1438

绝对差不超过限制的最长连续子数组

Find the longest subarray with elements whose absolute difference is within a specified limit using a sliding window app…

中等
1456

定长子串中元音的最大数目

Find the maximum number of vowels in a substring of a given length in a string using a sliding window approach.

中等
1499

满足不等式的最大值

Max Value of Equation asks to find the maximum value of a specific equation on a set of 2D points using sliding window t…

困难
1610

可见点的最大数目

Determine the maximum number of points visible from a fixed location within a given angle using a sliding window approac…

困难

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

按题型继续深入

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

route

引导式练习路径

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

开始引导练习arrow_forward
LeetCode 滑动窗口(状态滚动更新)模式题解:66题训练路线