题库chevron_right分类chevron_right矩阵
dashboard

矩阵

221 道题目
简单: 37中等: 125困难: 59

矩阵 是技术面试里最常出现的能力维度之一。建议先掌握基础题型的边界处理,再逐步过渡到模式识别和复杂度 trade-off。

面试场景

高频考察问题建模、边界条件与口头表达的清晰度。

常见误区

只背模板不解释为什么,容易在追问里失分。

练习策略

每轮练 3-5 题,固定复盘复杂度和可替代解法。

推荐练习顺序

#题目难度
36

有效的数独

Check if a 9x9 Sudoku board is valid by scanning rows, columns, and sub-boxes with hash lookups, ensuring no duplicates …

中等
37

解数独

Solve the Sudoku puzzle by filling empty cells while respecting Sudoku's rules using array scanning and backtracking.

困难
48

旋转图像

Rotate an n x n matrix 90 degrees clockwise in-place using array manipulation and mathematical indexing techniques effic…

中等
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…

中等
63

不同路径 II

Calculate the number of unique paths from top-left to bottom-right in a grid with obstacles using dynamic programming st…

中等
64

最小路径和

Compute the minimum sum from top-left to bottom-right in a grid using state transition dynamic programming efficiently.

中等
73

矩阵置零

Modify the matrix in place by setting rows and columns to zero when an element is zero.

中等
74

搜索二维矩阵

Search a 2D matrix efficiently using binary search over its linearized index, ensuring correctness in row-major sorted a…

中等
79

单词搜索

Solve Word Search with backtracking by exploring adjacent cells to match a target word in a grid.

中等
85

最大矩形

Compute the largest rectangle of 1's in a binary matrix using dynamic programming and stack-based state transitions effi…

困难
130

被围绕的区域

Transform the matrix in-place by marking regions surrounded by 'X' as 'X', while keeping border-adjacent 'O's intact.

中等
174

地下城游戏

Calculate the minimum initial health the knight needs to survive the dungeon using state transition dynamic programming …

困难
200

岛屿数量

Count the number of distinct islands in a binary grid using array traversal combined with depth-first search exploration…

中等
212

单词搜索 II

Solve the Word Search II problem using backtracking with pruning to find all words on a board of characters.

困难
221

最大正方形

Maximal Square is a matrix-based dynamic programming problem that focuses on finding the largest square filled with 1's.

中等
240

搜索二维矩阵 II

Efficiently search for a target in a 2D matrix using binary search and matrix properties.

中等
289

生命游戏

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

中等
304

二维区域和检索 - 矩阵不可变

Design a 2D matrix class that efficiently handles sum queries with O(1) time complexity using a prefix sum approach.

中等
329

矩阵中的最长递增路径

Find the length of the longest increasing path in a matrix with given movement constraints using graph techniques.

困难
363

矩形区域不超过 K 的最大数值和

Solve the "Max Sum of Rectangle No Larger Than K" problem using binary search over the valid sum space to optimize space…

困难
378

有序矩阵中第 K 小的元素

Find the kth smallest element in a sorted n x n matrix using efficient binary search or heap strategies for optimized me…

中等
407

接雨水 II

Solve Trapping Rain Water II using breadth-first search and priority queues for efficient water trapping in a matrix.

困难
417

太平洋大西洋水流问题

Find all cells on an island where water can flow to both the Pacific and Atlantic oceans using DFS or BFS.

中等
419

棋盘上的战舰

Count the number of non-overlapping battleships on a 2D board using array traversal and depth-first search patterns effi…

中等
427

建立四叉树

Construct a Quad-Tree from a binary matrix by recursively subdividing regions and tracking uniform states efficiently.

中等
463

岛屿的周长

Determine the perimeter of an island in a grid of land and water cells using DFS or BFS.

简单
498

对角线遍历

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

中等
529

扫雷游戏

Solve the Minesweeper game by updating revealed squares and handling clicks with Depth-First Search and Array manipulati…

中等
542

01 矩阵

The '01 Matrix' problem challenges you to find the nearest zero for each cell in a binary matrix using dynamic programmi…

中等
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…

简单
675

为高尔夫比赛砍树

Determine the minimum steps to cut all trees in a forest matrix in ascending height order using BFS traversal and priori…

困难
695

岛屿的最大面积

Find the largest connected land area in a binary grid using array traversal and depth-first search efficiently.

中等
733

图像渲染

Flood Fill is an array and DFS problem where you change connected pixels to a target color efficiently using recursion o…

简单
741

摘樱桃

Maximize cherries collected on a grid, employing state transition dynamic programming with careful navigation across obs…

困难
749

隔离病毒

Contain Virus involves using array-based Depth-First Search to contain viral spread by building walls around infected re…

困难
766

托普利茨矩阵

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

简单
773

滑动谜题

Determine the minimum moves to solve a 2x3 sliding puzzle using BFS and state transition dynamic programming techniques …

困难
778

水位上升的泳池中游泳

Solve the problem of swimming through a grid of rising water with a binary search on the valid answer space.

困难
782

变为棋盘

Determine the minimum swaps of rows or columns to convert an n x n binary board into a valid chessboard configuration.

困难
794

有效的井字游戏

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

中等
803

打砖块

Bricks Falling When Hit challenges your ability to simulate brick falls after sequential erasures using Union Find.

困难
807

保持城市天际线

Maximize building heights in a city grid without changing the skyline, using greedy selection constrained by row and col…

中等
827

最大人工岛

Calculate the largest island size by converting at most one zero in a binary grid using array and DFS techniques efficie…

困难
832

翻转图像

Flip each row of a binary matrix horizontally and invert its values efficiently using a two-pointer scanning approach.

简单
835

图像重叠

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

中等
840

矩阵中的幻方

Scan every 3x3 window, reject invalid digits fast, then verify row, column, and diagonal sums for Magic Squares In Grid.

中等
861

翻转矩阵后的得分

Maximize the score of a binary matrix by flipping rows and columns using a greedy approach and validation of invariants.

中等
864

获取所有钥匙的最短路径

Find the minimum steps to collect all keys in a grid using BFS and bitmasking, handling locks efficiently.

困难
867

转置矩阵

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

简单
883

三维形体投影面积

Calculate the projection area of a 3D shape defined by a grid of towers with varying heights.

简单
885

螺旋矩阵 III

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

中等
892

三维形体的表面积

Solve the Surface Area of 3D Shapes problem using array manipulation and mathematical formulas to calculate surface area…

简单
909

蛇梯棋

Solve the Snakes and Ladders problem using a BFS strategy to efficiently navigate the board and reach the final square.

中等
931

下降路径最小和

Minimum Falling Path Sum is a matrix dynamic programming problem where each cell depends on three reachable cells above …

中等
934

最短的桥

Find the minimum flips to connect two separate islands in a binary matrix using Array and DFS techniques efficiently.

中等
959

由斜杠划分区域

Determine the number of regions in a grid divided by slashes using array scanning and union-find techniques efficiently.

中等
980

不同路径 III

Solve the Unique Paths III problem using backtracking search with pruning to count 4-directional paths covering all empt…

困难
994

腐烂的橘子

Given a grid with fresh and rotten oranges, return the minimum time for all oranges to rot or -1 if impossible.

中等
999

可以被一步捕获的棋子数

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

简单
1020

飞地的数量

This problem involves finding the number of land cells that cannot reach the boundary in a grid using DFS and array mani…

中等
1030

距离顺序排列矩阵单元格

Compute all matrix cell coordinates sorted by Manhattan distance from a given center using array and math techniques eff…

简单
1034

边界着色

Given a grid and a starting cell, color all border cells of the connected component using DFS while preserving interior …

中等
1072

按列翻转得到最大值等行数

Maximize the number of equal rows in a binary matrix by flipping any number of columns.

中等
1074

元素和为目标值的子矩阵数量

Count all non-empty submatrices in a given matrix whose elements sum exactly to the target using efficient scanning tech…

困难
1091

二进制矩阵中的最短路径

Find the shortest clear path in a binary matrix using BFS, carefully handling obstacles and diagonal movements for effic…

中等
1139

最大的以 1 为边界的正方形

Find the largest square of 1s with 1s on its borders in a binary grid using dynamic programming.

中等
1162

地图分析

Find the farthest water cell from land in a grid and return the Manhattan distance using state transition dynamic progra…

中等
1210

穿过迷宫的最少移动次数

Find the minimum moves for a 2-cell snake to reach the bottom-right corner using rotations and BFS traversal in a grid.

困难
1219

黄金矿工

Find the path with the maximum gold in a grid with backtracking and pruning techniques to maximize the gold collected.

中等
1222

可以攻击国王的皇后

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

中等
1253

重构 2 行二进制矩阵

Reconstruct a 2-row binary matrix by distributing column sums while respecting upper and lower row limits using greedy p…

中等
1254

统计封闭岛屿的数目

Count the number of closed islands in a 2D grid using array traversal and depth-first search efficiently.

中等
1260

二维网格迁移

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

简单
1263

推箱子

Solve the minimum moves to push a box to its target using BFS and priority handling in a grid-based warehouse layout eff…

困难
1267

统计参与通信的服务器

Count Servers that Communicate involves identifying servers in a grid that can communicate based on row or column connec…

中等
1275

找出井字棋的获胜者

Determine the winner of a Tic Tac Toe game by scanning moves and using hash lookups for rows, columns, and diagonals eff…

简单
1277

统计全为 1 的正方形子矩阵

Count the number of square submatrices with all ones in a given binary matrix using dynamic programming.

中等
1284

转化为全零矩阵的最少反转次数

Compute the minimum flips to convert a binary matrix to zero by toggling cells and neighbors using array scanning plus h…

困难
1289

下降路径最小和 II

Find the minimum sum of a falling path in a square matrix using dynamic programming while avoiding same-column selection…

困难
1292

元素和小于等于阈值的正方形的最大边长

This problem challenges you to find the largest square in a matrix with a sum below a given threshold using binary searc…

中等
1293

网格中的最短路径

Find the shortest path in a grid with obstacles, allowing the elimination of up to k obstacles using BFS.

困难
1301

最大得分的路径数目

Calculate the maximum score path and count all valid routes in a square board with obstacles using dynamic programming.

困难
1314

矩阵区域和

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

中等
1329

将矩阵按对角线排序

Sort each diagonal of a matrix in ascending order, applying sorting and matrix traversal techniques.

中等
1337

矩阵中战斗力最弱的 K 行

Find the k weakest rows in a binary matrix where rows contain soldiers and civilians, using sorting and binary search te…

简单
1349

参加考试的最大学生数

Calculate the maximum number of students who can take an exam without cheating using state transition dynamic programmin…

困难
1351

统计有序矩阵中的负数

Count Negative Numbers in a Sorted Matrix requires counting negative numbers in a matrix sorted in non-increasing order …

简单
1368

使网格图至少有一条有效路径的最小代价

Determine the minimum cost to create at least one valid path from the top-left to bottom-right in a directional grid.

困难
1380

矩阵中的幸运数

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

简单
1391

检查网格中是否存在有效路径

Check if there is a valid path from the upper-left to the bottom-right corner of a grid using depth-first search.

中等
1439

有序矩阵中的第 k 个最小数组和

Find the kth smallest sum in a matrix with sorted rows using binary search and a heap-based approach.

困难
1444

切披萨的方案数

This problem challenges you to determine the number of valid ways to cut a pizza into pieces with apples using dynamic p…

困难
1463

摘樱桃 II

Maximize cherry collection in a grid using two robots with careful state transition dynamic programming to optimize path…

困难
1476

子矩形查询

Implement the SubrectangleQueries class to handle dynamic updates and value queries on a 2D rectangle.

中等
1504

统计全 1 子矩形

Count Submatrices With All Ones is a dynamic programming problem focusing on submatrix counting using an efficient row-b…

中等
1536

排布二进制网格的最少交换次数

Compute the minimum number of adjacent row swaps to transform a binary grid so all upper-triangle cells are zero using a…

中等
1559

二维网格图中探测环

Detect cycles in a 2D character grid using DFS while carefully tracking parent cells to avoid invalid revisits.

中等
1568

使陆地分离的最少天数

Find the minimum number of days to disconnect an island in a grid using depth-first search.

困难
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…

简单
1591

奇怪的打印机 II

Solve Strange Printer II by building color dependencies from bounding rectangles and checking whether a topological orde…

困难
1594

矩阵的最大非负积

Find the maximum non-negative product path in a matrix using dynamic programming and state transition.

中等
1595

连通两组点的最小成本

Compute the minimum cost to fully connect two groups of points using dynamic programming and bitmasking efficiently.

困难
1605

给定行和列的和求可行矩阵

Given row and column sums, find any valid matrix of non-negative integers that satisfies them.

中等
1631

最小体力消耗路径

Find the minimum effort required to travel from the top-left to the bottom-right of a grid, considering height differenc…

中等
1632

矩阵转换后的排名

Compute a unique rank matrix using graph indegree with topological ordering, ensuring each element reflects its relative…

困难
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…

中等
1727

重新排列后的最大子矩阵

Rearrange columns of a binary matrix to find the largest submatrix of 1s.

中等
1728

猫和老鼠 II

Cat and Mouse II requires determining if the mouse can reach food before being caught using graph and topological orderi…

困难
1738

找出第 K 大的异或坐标值

Compute the kth largest XOR coordinate in a 2D matrix using prefix sums, bit manipulation, and optimized selection techn…

中等
1765

地图中的最高点

Solve the Map of Highest Peak problem using breadth-first search to assign heights based on proximity to water cells.

中等
1861

旋转盒子

Rotate a box represented by a character matrix, letting stones fall under gravity using precise two-pointer scanning and…

中等
1878

矩阵中最大的三个菱形和

Find the three largest distinct rhombus sums from a given grid using array and math techniques.

中等
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.

中等
1901

寻找峰值 II

Locate any peak in a 2D matrix using binary search across rows or columns for efficient discovery and verification.

中等
1905

统计子岛屿

Identify and count all islands in grid2 that are fully contained within islands of grid1 using DFS traversal efficiently…

中等
1914

循环轮转矩阵

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

中等
1926

迷宫中离入口最近的出口

Find the shortest path from the maze entrance to the nearest border exit using BFS over a 2D array matrix efficiently.

中等
1937

扣分后的最大得分

Maximize your points in a matrix by selecting cells row by row while accounting for distance penalties using dynamic pro…

中等
1958

检查操作是否合法

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

中等
1970

你能穿过矩阵的最后一天

Find the last day to walk from top to bottom in a flooded matrix by using binary search and graph traversal techniques.

困难
1975

最大方阵和

Maximize the sum of an n x n integer matrix using row and column negation operations efficiently with a greedy approach.

中等
1981

最小化目标值与所选元素的差

This problem asks to select one element per row to minimize the absolute difference from a target sum using dynamic prog…

中等
1992

找到所有的农场组

Identify all rectangular farmland groups in a binary matrix using array traversal and depth-first search efficiently.

中等
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.

简单
2033

获取单值网格的最小操作数

Determine the fewest additions or subtractions of x to make all grid elements identical using array and math logic.

中等
2088

统计农场中肥沃金字塔的数目

Solve Count Fertile Pyramids in a Land with matrix DP that measures the tallest pyramid rooted at each fertile cell.

困难
2125

银行中的激光束数量

Calculate total laser beams in a bank floor plan using array counting and math logic between security devices on differe…

中等
2132

用邮票贴满网格图

Determine if a binary grid can be fully covered using fixed-size stamps by applying a greedy placement and validation st…

困难
2133

检查是否每一行每一列都包含全部整数

Determine if every row and column in a square matrix contains all numbers from 1 to n without repetition using array sca…

简单
2146

价格范围内最高排名的 K 样物品

Use BFS to rank reachable shop items by distance, price, row, and column, then return the best k coordinates.

中等
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…

中等
2258

逃离火灾

Maximize the time you can stay at your starting position before moving to safely reach the safehouse while avoiding fire…

困难
2267

检查是否有合法括号字符串路径

Check if there exists a valid parentheses string path in a given grid using state transition dynamic programming.

困难
2290

到达角落需要移除障碍物的最小数目

Find the minimum obstacles to remove in a 2D grid to reach the bottom-right corner using BFS graph traversal techniques.

困难
2304

网格中的最小路径代价

Minimize the cost of a path in a grid while considering move costs for each step.

中等
2319

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

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

简单
2326

螺旋矩阵 IV

In this problem, you need to generate a matrix filled with values from a linked list in a spiral order.

中等
2328

网格图中递增路径的数目

Solve Number of Increasing Paths in a Grid by turning cell comparisons into a DAG and counting paths with topological DP…

困难
2352

相等行列对

Identify all pairs of rows and columns in a square matrix that contain identical elements in the same sequence efficient…

中等
2373

矩阵中的局部最大值

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

简单
2392

给定条件下构造矩阵

Solve the matrix-building problem by using graph indegree and topological sorting to satisfy given row and column constr…

困难
2397

被列覆盖的最多行数

Select exactly numSelect columns from a binary matrix to maximize rows where all ones are covered efficiently using back…

中等
2428

沙漏的最大总和

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

中等
2435

矩阵中和能被 K 整除的路径

Compute all paths in a matrix where the sum of elements is divisible by k using state transition dynamic programming eff…

困难
2482

行和列中一和零的差值

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

中等
2500

删除每行中的最大值

Calculate the total of removed maximum values from each row of a matrix, iterating until all columns are deleted efficie…

简单
2503

矩阵查询可获得的最大分数

Solve the Maximum Number of Points From Grid Queries problem using two-pointer scanning and invariant tracking.

困难
2536

子矩阵元素加 1

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

中等
2545

根据第 K 场考试的分数排序

Sort a matrix of student scores by the kth exam efficiently using array manipulation and custom sorting techniques.

中等
2556

二进制矩阵中翻转最多一次使路径不连通

Determine if a single cell flip can disconnect a path from the top-left to bottom-right in a binary matrix efficiently u…

中等
2573

找出对应 LCP 矩阵的字符串

Determine the lexicographically smallest string matching a given LCP matrix using state transition dynamic programming.

困难
2577

在网格图中访问一个格子的最少时间

Compute the fastest path in a grid where each cell has a minimum time requirement using BFS and priority queue technique…

困难
2596

检查骑士巡视方案

Validate a knight's movement configuration on an n x n chessboard to check if it forms a valid Knight's Tour.

中等
2614

对角线上的质数

Find the largest prime number located on any diagonal of a square matrix using array iteration and prime checking techni…

简单
2617

网格图中最少访问的格子数

Determine the minimum number of cells to visit in a grid using state transition dynamic programming and efficient traver…

困难
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.

简单
2658

网格图中鱼的最大数目

Maximize the number of fish that can be caught by performing DFS on an optimal starting point in a grid.

中等
2661

找出叠涂元素

Find the first index where a row or column is completely painted in a matrix based on an array of integers.

中等
2679

矩阵中的和

Calculate the maximum score by repeatedly removing the largest elements from each row of a 2D matrix efficiently using s…

中等
2684

矩阵中移动的最大次数

Maximize the number of moves in a grid starting from the first column using state transition dynamic programming.

中等
2711

对角线上不同值的数量差

Find the difference in the number of distinct diagonal values in a matrix, returning results in a new matrix.

中等
2713

矩阵中严格递增的单元格数

Find the maximum number of cells that can be visited in a matrix by following strictly increasing values from a starting…

困难
2732

找到矩阵中的好子集

Find a Good Subset of the Matrix is a challenging problem involving array scanning, hash lookup, and bit manipulation to…

困难
2812

找出最安全路径

Find the Safest Path in a Grid uses binary search and BFS to maximize path safeness from thieves in a grid.

中等
2850

将石头分散到网格图的最少移动次数

Solve the problem of distributing 9 stones across a 3x3 grid with minimal moves using state transition dynamic programmi…

中等
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…

简单
2931

购买物品的最大开销

Maximize spending by carefully choosing the right items across multiple shops over m * n days.

困难
2946

循环移位后的矩阵相似检查

Determine if a matrix returns to its original state after performing cyclic row shifts k times using array and math patt…

简单
2965

找出缺失和重复的数字

Find the missing and repeated numbers in an n x n grid using array scanning and hash lookup.

简单
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…

简单
3044

出现频率最高的质数

Find the most frequent prime over 10 from numbers generated by scanning a 2D matrix in all straight directions efficient…

中等
3070

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

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

中等
3071

在矩阵上写出字母 Y 所需的最少操作次数

Find the minimum number of operations to write the letter Y on a grid by altering cell values.

中等
3122

使矩阵满足条件的最少操作次数

This problem asks to find the minimum number of operations on a 2D grid using state transition dynamic programming effic…

中等
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.

简单
3148

矩阵中的最大得分

Maximize the score in a grid by making moves to the bottom or right, using state transition dynamic programming.

中等
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.

中等
3225

网格图操作后的最大分数

Maximize your score by choosing the optimal sequence of column operations on a grid using dynamic programming transition…

困难
3239

最少翻转次数使二进制矩阵回文 I

Find the minimum flips to make a binary grid palindromic by scanning with two pointers and tracking symmetry efficiently…

中等
3240

最少翻转次数使二进制矩阵回文 II

The problem asks to flip cells in a binary grid to make its rows and columns palindromic using the minimum number of fli…

中等
3242

设计相邻元素求和服务

Design a service that computes sums for adjacent and diagonal elements in a 2D grid.

简单
3256

放三个车的价值之和最大 I

Maximize the value sum by placing three rooks on a chessboard while ensuring they do not attack each other.

困难
3257

放三个车的价值之和最大 II

Maximize the sum by placing three non-attacking rooks on a chessboard with dynamic programming.

困难
3276

选择矩阵中单元格的最大得分

Optimize selection of grid cells using state transition dynamic programming to maximize total sum efficiently.

困难
3286

穿越网格图的安全路径

Determine if you can safely traverse a binary grid from top-left to bottom-right using limited health points.

中等
3311

构造符合图结构的二维矩阵

This problem challenges you to construct a 2D grid from an undirected graph using a given set of edges.

困难
3332

旅客可以得到的最多点数

Calculate the maximum points a tourist can earn by choosing optimal city moves over k days using state transition DP.

中等
3341

到达最后一个房间的最少时间 I

Find Minimum Time to Reach Last Room I challenges you to determine the minimum time to travel in a dungeon with a grid l…

中等
3342

到达最后一个房间的最少时间 II

Calculate the minimum time to reach the last room in a grid with alternating move times using array and graph patterns.

中等
3363

最多可收集的水果数目

Maximize the number of fruits collected by three children navigating a grid dungeon with dynamic programming.

困难
3393

统计异或值为给定值的路径数目

Count the number of paths in a grid where the XOR of all values along the path equals a given number.

中等
3402

使每一列严格递增的最少操作次数

Calculate the minimum increments to make each column of a matrix strictly increasing using a greedy invariant approach.

简单
3417

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

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

简单
3418

机器人可以获得的最大金币数

Find the maximum amount of money a robot can collect while neutralizing robbers on its path in a grid.

中等
3446

按对角线进行矩阵排序

Sort Matrix by Diagonals groups cells by diagonal, then sorts bottom-left diagonals descending and top-right diagonals a…

中等
3459

最长 V 形对角线段的长度

Compute the maximum length of a V-shaped diagonal segment in a 2D integer matrix using state transition dynamic programm…

困难
3462

提取至多 K 个元素的最大总和

Find the maximum sum by selecting at most k elements from a 2D matrix respecting per-row limits using a greedy strategy.

中等
3484

设计电子表格

Design a spreadsheet that supports setting, retrieving, and resetting values, with the ability to handle formulas refere…

中等
3529

统计水平子串和垂直子串重叠格子的数目

Efficiently count grid cells appearing in both horizontal and vertical occurrences of a given string pattern using array…

中等
3537

填充特殊网格

Fill a Special Grid uses recursive divide-and-conquer to populate a 2^n x 2^n matrix with sequential integers uniquely i…

中等
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…

中等
3548

等和矩阵分割 II

Determine if a matrix can be partitioned into two sections with an equal sum using a single cut.

困难
3552

网格传送门旅游

Find the minimum moves to traverse a 2D grid using standard steps and one-time portal teleports efficiently.

中等
3567

子矩阵的最小绝对差

Find the minimum absolute difference in each k x k submatrix within a given 2D grid using array and sorting techniques.

中等
3568

清理教室的最少移动

Solve the "Minimum Moves to Clean the Classroom" problem using array scanning and hash lookup for an optimized solution.

中等
3603

交替方向的最小路径代价 II

This problem focuses on finding the minimum cost path with alternating directions in a grid using dynamic programming.

中等
3619

总价值可以被 K 整除的岛屿数目

Count the number of islands in a grid where the sum of each island's values is divisible by a given integer k.

中等

关联高频模式

LeetCode 矩阵题型题解:221题训练路线