题库chevron_right解题模式chevron_right双·指针·invariant
schema可复用解题模式

双·指针·invariant模式

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

database99 道题tune37/56/6 难度梯度category6 个关联题型

模式摘要

先识别什么

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

解法节奏

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

高频失分点

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

识别信号

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

解题流程

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

常见失分点

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

推荐题单梯度

题库

双·指针·invariant模式题库

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

慢加载模式题库

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

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

当前展示 24 / 99 道题目

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

盛最多水的容器

Find two vertical lines that can form a container with the most water in a given array of heights.

中等
15

三数之和

Given an integer array, return all unique triplets where the sum is zero using two-pointer scanning with careful duplica…

中等
16

最接近的三数之和

Find the sum of three integers in an array that is closest to a given target using two-pointer scanning.

中等
18

四数之和

The 4Sum problem requires finding all unique quadruplets in an array that sum to a specific target value.

中等
26

删除有序数组中的重复项

Learn how to remove duplicates from a sorted array in-place using two-pointer scanning while preserving element order.

简单
27

移除元素

Remove Element challenges you to remove a value from an array in-place using efficient two-pointer scanning and tracking…

简单
28

找出字符串中第一个匹配项的下标

Locate the first occurrence of a substring within a string using a two-pointer scanning strategy and invariant tracking …

简单
31

下一个排列

Next Permutation is a medium-difficulty problem focusing on generating the next lexicographically greater permutation of…

中等
75

颜色分类

Sort Colors requires in-place reordering of an array using a two-pointer scanning strategy to group 0s, 1s, and 2s effic…

中等
80

删除有序数组中的重复项 II

Solve the problem of removing duplicates from a sorted array in-place, ensuring each element appears at most twice, usin…

中等
88

合并两个有序数组

Merge two sorted arrays into the first array in non-decreasing order, using a two-pointer approach.

简单
125

验证回文串

Check if a given string is a valid palindrome by using two-pointer scanning and invariant tracking techniques.

简单
151

反转字符串中的单词

Reverse Words in a String requires reordering words using precise two-pointer scanning with careful space handling for e…

中等
165

比较版本号

Compare two version numbers by checking their individual revisions, considering missing revisions as zero, using a two-p…

中等
189

轮转数组

Rotate Array challenges you to shift elements right by k steps using precise two-pointer scanning and invariant tracking…

中等
202

快乐数

Determine if a number is happy by repeatedly summing squares of digits using two-pointer scanning to detect cycles effic…

简单
283

移动零

Move all zeros in an array to the end while preserving the order of non-zero elements using efficient in-place operation…

简单
295

数据流的中位数

Implement a MedianFinder class that supports adding numbers and finding the median from a data stream.

困难
321

拼接最大数

Create Maximum Number involves merging digits from two arrays while preserving order, maximizing the resulting number.

困难
344

反转字符串

Reverse a character array in-place using a two-pointer scanning technique, ensuring minimal memory and correct index swa…

简单
345

反转字符串中的元音字母

Reverse Vowels of a String uses a two-pointer approach to reverse the vowels in a string while leaving the consonants in…

简单
443

压缩字符串

Compress a character array in-place by converting consecutive repeated characters into counts using two-pointer scanning…

中等
455

分发饼干

Maximize content children by assigning at most one cookie per child using two-pointer scanning and greedy sorting techni…

简单
481

神奇字符串

Count the number of '1's in the first n characters of a magical string using two-pointer scanning and invariant tracking…

中等

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

按题型继续深入

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

route

引导式练习路径

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

开始引导练习arrow_forward
LeetCode 双·指针·invariant模式题解:99题训练路线