题库chevron_right解题模式chevron_right数组·matrix
schema可复用解题模式

数组·matrix模式

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

database48 道题tune21/26/1 难度梯度category4 个关联题型

模式摘要

先识别什么

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

解法节奏

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

高频失分点

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

识别信号

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

解题流程

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

常见失分点

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

推荐题单梯度

题库

数组·matrix模式题库

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

慢加载模式题库

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

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

当前展示 24 / 48 道题目

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

螺旋矩阵

Given an m x n matrix, return all elements in spiral order starting from the top-left corner.

中等
59

螺旋矩阵 II

Generate a spiral matrix of size n x n, filled with elements from 1 to n² in spiral order, for interview-focused solving…

中等
289

生命游戏

Solve the Game of Life by updating each cell based on its eight neighbors using Array and Matrix simulation patterns eff…

中等
498

对角线遍历

Traverse a matrix diagonally and return all elements in the specific zig-zag order required by the problem pattern.

中等
566

重塑矩阵

Reshape the Matrix involves transforming a 2D matrix into a new matrix with the same elements in row-major order, follow…

简单
661

图片平滑器

Apply a 3x3 smoothing filter to a matrix, rounding down each cell average including surrounding neighbors for accurate r…

简单
766

托普利茨矩阵

Determine if a given matrix is a Toeplitz matrix by checking diagonal consistency.

简单
794

有效的井字游戏

Verify if a given Tic-Tac-Toe board can represent a valid game state during a valid sequence of moves.

中等
835

图像重叠

Image Overlap requires calculating the overlap between two binary matrices by translating one image over the other.

中等
867

转置矩阵

Transpose Matrix problem requires flipping a matrix's rows and columns to return the transposed version.

简单
885

螺旋矩阵 III

Solve the Spiral Matrix III problem by simulating the movement across a matrix with specific constraints on direction an…

中等
999

可以被一步捕获的棋子数

This problem involves finding the number of pawns a rook can capture on a chessboard, considering obstacles like bishops…

简单
1222

可以攻击国王的皇后

Identify all black queens on an 8x8 chessboard that can attack the white king using array and matrix simulation techniqu…

中等
1260

二维网格迁移

Shift 2D Grid requires shifting elements of a matrix by a given number of times, simulating step-by-step movement.

简单
1314

矩阵区域和

Compute a matrix where each cell contains the sum of all elements within k-distance blocks using prefix sums efficiently…

中等
1380

矩阵中的幸运数

The Lucky Numbers in a Matrix problem involves finding elements that are the minimum in their row and maximum in their c…

简单
1572

矩阵对角线元素的和

Calculate the sum of both primary and secondary diagonals in a square matrix while avoiding double-counting overlaps.

简单
1582

二进制矩阵中的特殊位置

Identify all special positions in a binary matrix where a 1 has no other 1s in its row or column, ensuring optimal array…

简单
1672

最富有客户的资产总量

Calculate the richest customer's wealth by summing the amounts in each customer's bank accounts in a matrix.

简单
1706

球会落何处

Determine where each ball exits a diagonal board grid or if it gets stuck, using matrix simulation with careful traversa…

中等
1886

判断矩阵经轮转后是否一致

Determine if a binary matrix can be transformed into another by rotating it 90 degrees multiple times.

简单
1895

最大的幻方

Find the side length of the largest magic square in a matrix where row, column, and diagonal sums are equal.

中等
1914

循环轮转矩阵

This problem requires cyclically rotating a grid by rotating each layer of the matrix counter-clockwise for a specified …

中等
1958

检查操作是否合法

Determine if a move on an 8x8 board is legal by validating lines in all directions using array and matrix patterns.

中等

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

按题型继续深入

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

route

引导式练习路径

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

开始引导练习arrow_forward
LeetCode 数组·matrix模式题解:48题训练路线