LeetCodechevron_rightCategorieschevron_rightmatrix
dashboard

matrix

221 problems
Easy: 37Medium: 125Hard: 59

matrix is one of the most repeated interview dimensions. Start with edge-safe fundamentals, then move into pattern-level trade-offs.

Interview Signal

Frequently tests problem modeling, edge handling, and verbal clarity.

Common Pitfall

Template-only answers break under follow-up questioning.

Practice Strategy

Practice in 3-5 problem rounds and always review complexity alternatives.

Recommended Progression

#TitleDifficulty
36

Valid Sudoku

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

Medium
37

Sudoku Solver

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

Hard
48

Rotate Image

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

Medium
54

Spiral Matrix

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

Medium
59

Spiral Matrix II

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

Medium
63

Unique Paths II

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

Medium
64

Minimum Path Sum

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

Medium
73

Set Matrix Zeroes

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

Medium
74

Search a 2D Matrix

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

Medium
79

Word Search

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

Medium
85

Maximal Rectangle

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

Hard
130

Surrounded Regions

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

Medium
174

Dungeon Game

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

Hard
200

Number of Islands

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

Medium
212

Word Search II

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

Hard
221

Maximal Square

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

Medium
240

Search a 2D Matrix II

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

Medium
289

Game of Life

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

Medium
304

Range Sum Query 2D - Immutable

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

Medium
329

Longest Increasing Path in a Matrix

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

Hard
363

Max Sum of Rectangle No Larger Than K

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

Hard
378

Kth Smallest Element in a Sorted Matrix

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

Medium
407

Trapping Rain Water II

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

Hard
417

Pacific Atlantic Water Flow

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

Medium
419

Battleships in a Board

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

Medium
427

Construct Quad Tree

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

Medium
463

Island Perimeter

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

Easy
498

Diagonal Traverse

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

Medium
529

Minesweeper

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

Medium
542

01 Matrix

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

Medium
566

Reshape the Matrix

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

Easy
661

Image Smoother

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

Easy
675

Cut Off Trees for Golf Event

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

Hard
695

Max Area of Island

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

Medium
733

Flood Fill

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

Easy
741

Cherry Pickup

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

Hard
749

Contain Virus

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

Hard
766

Toeplitz Matrix

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

Easy
773

Sliding Puzzle

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

Hard
778

Swim in Rising Water

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

Hard
782

Transform to Chessboard

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

Hard
794

Valid Tic-Tac-Toe State

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

Medium
803

Bricks Falling When Hit

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

Hard
807

Max Increase to Keep City Skyline

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

Medium
827

Making A Large Island

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

Hard
832

Flipping an Image

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

Easy
835

Image Overlap

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

Medium
840

Magic Squares In Grid

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

Medium
861

Score After Flipping Matrix

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

Medium
864

Shortest Path to Get All Keys

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

Hard
867

Transpose Matrix

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

Easy
883

Projection Area of 3D Shapes

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

Easy
885

Spiral Matrix III

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

Medium
892

Surface Area of 3D Shapes

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

Easy
909

Snakes and Ladders

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

Medium
931

Minimum Falling Path Sum

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

Medium
934

Shortest Bridge

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

Medium
959

Regions Cut By Slashes

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

Medium
980

Unique Paths III

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

Hard
994

Rotting Oranges

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

Medium
999

Available Captures for Rook

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

Easy
1020

Number of Enclaves

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

Medium
1030

Matrix Cells in Distance Order

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

Easy
1034

Coloring A Border

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

Medium
1072

Flip Columns For Maximum Number of Equal Rows

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

Medium
1074

Number of Submatrices That Sum to Target

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

Hard
1091

Shortest Path in Binary Matrix

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

Medium
1139

Largest 1-Bordered Square

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

Medium
1162

As Far from Land as Possible

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

Medium
1210

Minimum Moves to Reach Target with Rotations

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

Hard
1219

Path with Maximum Gold

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

Medium
1222

Queens That Can Attack the King

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

Medium
1253

Reconstruct a 2-Row Binary Matrix

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

Medium
1254

Number of Closed Islands

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

Medium
1260

Shift 2D Grid

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

Easy
1263

Minimum Moves to Move a Box to Their Target Location

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

Hard
1267

Count Servers that Communicate

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

Medium
1275

Find Winner on a Tic Tac Toe Game

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

Easy
1277

Count Square Submatrices with All Ones

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

Medium
1284

Minimum Number of Flips to Convert Binary Matrix to Zero Matrix

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

Hard
1289

Minimum Falling Path Sum II

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

Hard
1292

Maximum Side Length of a Square with Sum Less than or Equal to Threshold

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

Medium
1293

Shortest Path in a Grid with Obstacles Elimination

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

Hard
1301

Number of Paths with Max Score

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

Hard
1314

Matrix Block Sum

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

Medium
1329

Sort the Matrix Diagonally

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

Medium
1337

The K Weakest Rows in a Matrix

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

Easy
1349

Maximum Students Taking Exam

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

Hard
1351

Count Negative Numbers in a Sorted Matrix

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

Easy
1368

Minimum Cost to Make at Least One Valid Path in a Grid

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

Hard
1380

Lucky Numbers in a Matrix

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

Easy
1391

Check if There is a Valid Path in a Grid

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

Medium
1439

Find the Kth Smallest Sum of a Matrix With Sorted Rows

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

Hard
1444

Number of Ways of Cutting a Pizza

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

Hard
1463

Cherry Pickup II

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

Hard
1476

Subrectangle Queries

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

Medium
1504

Count Submatrices With All Ones

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

Medium
1536

Minimum Swaps to Arrange a Binary Grid

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

Medium
1559

Detect Cycles in 2D Grid

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

Medium
1568

Minimum Number of Days to Disconnect Island

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

Hard
1572

Matrix Diagonal Sum

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

Easy
1582

Special Positions in a Binary Matrix

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

Easy
1591

Strange Printer II

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

Hard
1594

Maximum Non Negative Product in a Matrix

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

Medium
1595

Minimum Cost to Connect Two Groups of Points

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

Hard
1605

Find Valid Matrix Given Row and Column Sums

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

Medium
1631

Path With Minimum Effort

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

Medium
1632

Rank Transform of a Matrix

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

Hard
1672

Richest Customer Wealth

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

Easy
1706

Where Will the Ball Fall

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

Medium
1727

Largest Submatrix With Rearrangements

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

Medium
1728

Cat and Mouse II

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

Hard
1738

Find Kth Largest XOR Coordinate Value

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

Medium
1765

Map of Highest Peak

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

Medium
1861

Rotating the Box

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

Medium
1878

Get Biggest Three Rhombus Sums in a Grid

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

Medium
1886

Determine Whether Matrix Can Be Obtained By Rotation

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

Easy
1895

Largest Magic Square

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

Medium
1901

Find a Peak Element II

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

Medium
1905

Count Sub Islands

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

Medium
1914

Cyclically Rotating a Grid

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

Medium
1926

Nearest Exit from Entrance in Maze

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

Medium
1937

Maximum Number of Points with Cost

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

Medium
1958

Check if Move is Legal

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

Medium
1970

Last Day Where You Can Still Cross

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

Hard
1975

Maximum Matrix Sum

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

Medium
1981

Minimize the Difference Between Target and Chosen Elements

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

Medium
1992

Find All Groups of Farmland

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

Medium
2017

Grid Game

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

Medium
2018

Check if Word Can Be Placed In Crossword

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

Medium
2022

Convert 1D Array Into 2D Array

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

Easy
2033

Minimum Operations to Make a Uni-Value Grid

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

Medium
2088

Count Fertile Pyramids in a Land

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

Hard
2125

Number of Laser Beams in a Bank

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

Medium
2132

Stamping the Grid

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

Hard
2133

Check if Every Row and Column Contains All Numbers

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

Easy
2146

K Highest Ranked Items Within a Price Range

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

Medium
2245

Maximum Trailing Zeros in a Cornered Path

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

Medium
2257

Count Unguarded Cells in the Grid

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

Medium
2258

Escape the Spreading Fire

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

Hard
2267

Check if There Is a Valid Parentheses String Path

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

Hard
2290

Minimum Obstacle Removal to Reach Corner

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

Hard
2304

Minimum Path Cost in a Grid

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

Medium
2319

Check if Matrix Is X-Matrix

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

Easy
2326

Spiral Matrix IV

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

Medium
2328

Number of Increasing Paths in a Grid

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

Hard
2352

Equal Row and Column Pairs

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

Medium
2373

Largest Local Values in a Matrix

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

Easy
2392

Build a Matrix With Conditions

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

Hard
2397

Maximum Rows Covered by Columns

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

Medium
2428

Maximum Sum of an Hourglass

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

Medium
2435

Paths in Matrix Whose Sum Is Divisible by K

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

Hard
2482

Difference Between Ones and Zeros in Row and Column

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

Medium
2500

Delete Greatest Value in Each Row

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

Easy
2503

Maximum Number of Points From Grid Queries

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

Hard
2536

Increment Submatrices by One

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

Medium
2545

Sort the Students by Their Kth Score

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

Medium
2556

Disconnect Path in a Binary Matrix by at Most One Flip

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

Medium
2573

Find the String with LCP

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

Hard
2577

Minimum Time to Visit a Cell In a Grid

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

Hard
2596

Check Knight Tour Configuration

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

Medium
2614

Prime In Diagonal

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

Easy
2617

Minimum Number of Visited Cells in a Grid

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

Hard
2639

Find the Width of Columns of a Grid

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…

Easy
2643

Row With Maximum Ones

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

Easy
2658

Maximum Number of Fish in a Grid

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

Medium
2661

First Completely Painted Row or Column

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

Medium
2679

Sum in a Matrix

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

Medium
2684

Maximum Number of Moves in a Grid

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

Medium
2711

Difference of Number of Distinct Values on Diagonals

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

Medium
2713

Maximum Strictly Increasing Cells in a Matrix

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

Hard
2732

Find a Good Subset of the Matrix

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

Hard
2812

Find the Safest Path in a Grid

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

Medium
2850

Minimum Moves to Spread Stones Over Grid

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

Medium
2906

Construct Product Matrix

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

Medium
2923

Find Champion I

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

Easy
2931

Maximum Spending After Buying Items

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

Hard
2946

Matrix Similarity After Cyclic Shifts

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

Easy
2965

Find Missing and Repeated Values

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

Easy
3030

Find the Grid of Region Average

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

Medium
3033

Modify the Matrix

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

Easy
3044

Most Frequent Prime

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

Medium
3070

Count Submatrices with Top-Left Element and Sum Less Than k

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

Medium
3071

Minimum Operations to Write the Letter Y on a Grid

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

Medium
3122

Minimum Number of Operations to Satisfy Conditions

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

Medium
3127

Make a Square with the Same Color

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

Easy
3142

Check if Grid Satisfies Conditions

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

Easy
3148

Maximum Difference Score in a Grid

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

Medium
3195

Find the Minimum Area to Cover All Ones I

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

Medium
3197

Find the Minimum Area to Cover All Ones II

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

Hard
3212

Count Submatrices With Equal Frequency of X and Y

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

Medium
3225

Maximum Score From Grid Operations

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

Hard
3239

Minimum Number of Flips to Make Binary Grid Palindromic I

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

Medium
3240

Minimum Number of Flips to Make Binary Grid Palindromic II

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

Medium
3242

Design Neighbor Sum Service

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

Easy
3256

Maximum Value Sum by Placing Three Rooks I

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

Hard
3257

Maximum Value Sum by Placing Three Rooks II

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

Hard
3276

Select Cells in Grid With Maximum Score

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

Hard
3286

Find a Safe Walk Through a Grid

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

Medium
3311

Construct 2D Grid Matching Graph Layout

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

Hard
3332

Maximum Points Tourist Can Earn

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

Medium
3341

Find Minimum Time to Reach Last Room 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…

Medium
3342

Find Minimum Time to Reach Last Room II

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

Medium
3363

Find the Maximum Number of Fruits Collected

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

Hard
3393

Count Paths With the Given XOR Value

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

Medium
3402

Minimum Operations to Make Columns Strictly Increasing

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

Easy
3417

Zigzag Grid Traversal With Skip

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

Easy
3418

Maximum Amount of Money Robot Can Earn

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

Medium
3446

Sort Matrix by Diagonals

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

Medium
3459

Length of Longest V-Shaped Diagonal Segment

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

Hard
3462

Maximum Sum With at Most K Elements

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

Medium
3484

Design Spreadsheet

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

Medium
3529

Count Cells in Overlapping Horizontal and Vertical Substrings

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

Medium
3537

Fill a Special Grid

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

Medium
3546

Equal Sum Grid Partition 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…

Medium
3548

Equal Sum Grid Partition II

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

Hard
3552

Grid Teleportation Traversal

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

Medium
3567

Minimum Absolute Difference in Sliding Submatrix

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

Medium
3568

Minimum Moves to Clean the Classroom

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

Medium
3603

Minimum Cost Path with Alternating Directions II

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

Medium
3619

Count Islands With Total Value Divisible by K

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

Medium

Related Patterns

Matrix LeetCode Problems: 221 Solutions