题库chevron_right数组·matrix

数组·matrix 模式

48 道题目

模式页适合用来建立可复用解题框架。先识别题目特征,再按固定流程解释状态定义、转移和边界。

识别信号

  • Do you understand the process of adjusting boundaries dynamically in a spiral traversal?
  • Can you explain how the simulation approach helps to cover all matrix elements in spiral order?
  • The candidate demonstrates an understanding of array traversal techniques.

解题流程

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

常见失分点

  • Not adjusting the boundaries after each pass (top, bottom, left, right) will cause revisiting the same elements.
  • Forgetting to adjust the boundaries after completing a row or column, causing an infinite loop or overwriting cells.
  • Updating cells in a single pass without markers causes neighbor counts to be incorrect.

推荐题单梯度

#题目难度
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.

中等
2017

网格游戏

Solve the Grid Game problem by optimizing the movement of two robots on a 2D matrix grid.

中等
2018

判断单词是否能放入填字游戏内

Determine if a word fits in a crossword grid using array and matrix checks, accounting for spaces, letters, and blocked …

中等
2022

将一维数组转变成二维数组

Convert a 1D integer array into a structured 2D array with specified rows and columns using all elements sequentially.

简单
2245

转角路径的乘积中最多能有几个尾随零

Find the maximum trailing zeros in the product of a cornered path within a 2D grid.

中等
2257

统计网格图中没有被保卫的格子数

Solve Count Unguarded Cells in the Grid by marking guard sight lines across a blocked matrix and counting untouched empt…

中等
2319

判断矩阵是否是一个 X 矩阵

Check if a square matrix follows the X-Matrix pattern by validating diagonal and non-diagonal conditions.

简单
2373

矩阵中的局部最大值

Find the largest value in every 3x3 submatrix of an n x n integer matrix efficiently using nested loops.

简单
2428

沙漏的最大总和

Calculate the maximum sum of an hourglass in a 2D matrix using array traversal and submatrix evaluation techniques effic…

中等
2482

行和列中一和零的差值

This problem requires computing a difference matrix based on the ones and zeros in each row and column of a binary matri…

中等
2536

子矩阵元素加 1

Increment Submatrices by One focuses on efficiently updating submatrices using row-wise prefix sums in an n by n matrix.

中等
2639

查询网格图中每一列的宽度

This problem asks you to compute the width of each column in a grid, where the width is defined by the length of the lar…

简单
2643

一最多的行

Find the row with the maximum ones in a binary matrix and return its index and count.

简单
2906

构造乘积矩阵

Solve the "Construct Product Matrix" problem by calculating the product of elements in 2D matrices without division.

中等
2923

找到冠军 I

Find Champion I is an easy problem focusing on identifying the strongest team in a tournament using matrix-based compari…

简单
3030

找出网格的区域平均强度

Find the Grid of Region Average requires identifying regions in a matrix where pixel differences are below a threshold, …

中等
3033

修改矩阵

Modify the Matrix efficiently by replacing all -1 elements with the maximum in their column using array and matrix opera…

简单
3070

元素和小于等于 k 的子矩阵的数目

Count all submatrices including the top-left element with sum less than k using array and matrix prefix sum strategies.

中等
3127

构造相同颜色的正方形

Determine if a 3x3 grid can form a 2x2 square of the same color by changing at most one cell efficiently.

简单
3142

判断矩阵是否满足条件

Check if a grid satisfies given conditions by analyzing array and matrix structure with specific checks on values.

简单
3195

包含所有 1 的最小矩形面积 I

Find the smallest rectangle to cover all 1's in a 2D binary matrix, focusing on array and matrix handling.

中等
3197

包含所有 1 的最小矩形面积 II

Find the minimum area to cover all 1's in a 2D binary grid using three non-overlapping rectangles.

困难
3212

统计 X 和 Y 频数相等的子矩阵数量

Count the number of submatrices with equal frequency of 'X' and 'Y' in a 2D character grid.

中等
3417

跳过交替单元格的之字形遍历

Traverse a 2D grid in a zigzag pattern while skipping alternate cells, focusing on array and matrix manipulation challen…

简单
3546

等和矩阵分割 I

Determine if an m x n matrix grid can be split into two non-empty sections with equal sums by making a single horizontal…

中等

关联题型

LeetCode 数组·matrix模式题解:48题训练路线