Matrix Problems
221 Matrix LeetCode problems · Solve with AI-powered hints & step-by-step explanations.
Learn the coding interview patterns behind these problems.
Start with these
All Matrix problems
36 Valid Sudoku Medium37 Sudoku Solver Hard48 Rotate Image Medium54 Spiral Matrix Medium59 Spiral Matrix II Medium63 Unique Paths II Medium64 Minimum Path Sum Medium73 Set Matrix Zeroes Medium74 Search a 2D Matrix Medium79 Word Search Medium85 Maximal Rectangle Hard130 Surrounded Regions Medium174 Dungeon Game Hard200 Number of Islands Medium212 Word Search II Hard221 Maximal Square Medium240 Search a 2D Matrix II Medium289 Game of Life Medium304 Range Sum Query 2D - Immutable Medium329 Longest Increasing Path in a Matrix Hard363 Max Sum of Rectangle No Larger Than K Hard378 Kth Smallest Element in a Sorted Matrix Medium407 Trapping Rain Water II Hard417 Pacific Atlantic Water Flow Medium419 Battleships in a Board Medium427 Construct Quad Tree Medium463 Island Perimeter Easy498 Diagonal Traverse Medium529 Minesweeper Medium542 01 Matrix Medium566 Reshape the Matrix Easy661 Image Smoother Easy675 Cut Off Trees for Golf Event Hard695 Max Area of Island Medium733 Flood Fill Easy741 Cherry Pickup Hard749 Contain Virus Hard766 Toeplitz Matrix Easy773 Sliding Puzzle Hard778 Swim in Rising Water Hard782 Transform to Chessboard Hard794 Valid Tic-Tac-Toe State Medium803 Bricks Falling When Hit Hard807 Max Increase to Keep City Skyline Medium827 Making A Large Island Hard832 Flipping an Image Easy835 Image Overlap Medium840 Magic Squares In Grid Medium861 Score After Flipping Matrix Medium864 Shortest Path to Get All Keys Hard867 Transpose Matrix Easy883 Projection Area of 3D Shapes Easy885 Spiral Matrix III Medium892 Surface Area of 3D Shapes Easy909 Snakes and Ladders Medium931 Minimum Falling Path Sum Medium934 Shortest Bridge Medium959 Regions Cut By Slashes Medium980 Unique Paths III Hard994 Rotting Oranges Medium999 Available Captures for Rook Easy1020 Number of Enclaves Medium1030 Matrix Cells in Distance Order Easy1034 Coloring A Border Medium1072 Flip Columns For Maximum Number of Equal Rows Medium1074 Number of Submatrices That Sum to Target Hard1091 Shortest Path in Binary Matrix Medium1139 Largest 1-Bordered Square Medium1162 As Far from Land as Possible Medium1210 Minimum Moves to Reach Target with Rotations Hard1219 Path with Maximum Gold Medium1222 Queens That Can Attack the King Medium1253 Reconstruct a 2-Row Binary Matrix Medium1254 Number of Closed Islands Medium1260 Shift 2D Grid Easy1263 Minimum Moves to Move a Box to Their Target Location Hard1267 Count Servers that Communicate Medium1275 Find Winner on a Tic Tac Toe Game Easy1277 Count Square Submatrices with All Ones Medium1284 Minimum Number of Flips to Convert Binary Matrix to Zero Matrix Hard1289 Minimum Falling Path Sum II Hard1292 Maximum Side Length of a Square with Sum Less than or Equal to Threshold Medium1293 Shortest Path in a Grid with Obstacles Elimination Hard1301 Number of Paths with Max Score Hard1314 Matrix Block Sum Medium1329 Sort the Matrix Diagonally Medium1337 The K Weakest Rows in a Matrix Easy1349 Maximum Students Taking Exam Hard1351 Count Negative Numbers in a Sorted Matrix Easy1368 Minimum Cost to Make at Least One Valid Path in a Grid Hard1380 Lucky Numbers in a Matrix Easy1391 Check if There is a Valid Path in a Grid Medium1439 Find the Kth Smallest Sum of a Matrix With Sorted Rows Hard1444 Number of Ways of Cutting a Pizza Hard1463 Cherry Pickup II Hard1476 Subrectangle Queries Medium1504 Count Submatrices With All Ones Medium1536 Minimum Swaps to Arrange a Binary Grid Medium1559 Detect Cycles in 2D Grid Medium1568 Minimum Number of Days to Disconnect Island Hard1572 Matrix Diagonal Sum Easy1582 Special Positions in a Binary Matrix Easy1591 Strange Printer II Hard1594 Maximum Non Negative Product in a Matrix Medium1595 Minimum Cost to Connect Two Groups of Points Hard1605 Find Valid Matrix Given Row and Column Sums Medium1631 Path With Minimum Effort Medium1632 Rank Transform of a Matrix Hard1672 Richest Customer Wealth Easy1706 Where Will the Ball Fall Medium1727 Largest Submatrix With Rearrangements Medium1728 Cat and Mouse II Hard1738 Find Kth Largest XOR Coordinate Value Medium1765 Map of Highest Peak Medium1861 Rotating the Box Medium1878 Get Biggest Three Rhombus Sums in a Grid Medium1886 Determine Whether Matrix Can Be Obtained By Rotation Easy1895 Largest Magic Square Medium1901 Find a Peak Element II Medium1905 Count Sub Islands Medium1914 Cyclically Rotating a Grid Medium1926 Nearest Exit from Entrance in Maze Medium1937 Maximum Number of Points with Cost Medium1958 Check if Move is Legal Medium1970 Last Day Where You Can Still Cross Hard1975 Maximum Matrix Sum Medium1981 Minimize the Difference Between Target and Chosen Elements Medium1992 Find All Groups of Farmland Medium2017 Grid Game Medium2018 Check if Word Can Be Placed In Crossword Medium2022 Convert 1D Array Into 2D Array Easy2033 Minimum Operations to Make a Uni-Value Grid Medium2088 Count Fertile Pyramids in a Land Hard2125 Number of Laser Beams in a Bank Medium2132 Stamping the Grid Hard2133 Check if Every Row and Column Contains All Numbers Easy2146 K Highest Ranked Items Within a Price Range Medium2245 Maximum Trailing Zeros in a Cornered Path Medium2257 Count Unguarded Cells in the Grid Medium2258 Escape the Spreading Fire Hard2267 Check if There Is a Valid Parentheses String Path Hard2290 Minimum Obstacle Removal to Reach Corner Hard2304 Minimum Path Cost in a Grid Medium2319 Check if Matrix Is X-Matrix Easy2326 Spiral Matrix IV Medium2328 Number of Increasing Paths in a Grid Hard2352 Equal Row and Column Pairs Medium2373 Largest Local Values in a Matrix Easy2392 Build a Matrix With Conditions Hard2397 Maximum Rows Covered by Columns Medium2428 Maximum Sum of an Hourglass Medium2435 Paths in Matrix Whose Sum Is Divisible by K Hard2482 Difference Between Ones and Zeros in Row and Column Medium2500 Delete Greatest Value in Each Row Easy2503 Maximum Number of Points From Grid Queries Hard2536 Increment Submatrices by One Medium2545 Sort the Students by Their Kth Score Medium2556 Disconnect Path in a Binary Matrix by at Most One Flip Medium2573 Find the String with LCP Hard2577 Minimum Time to Visit a Cell In a Grid Hard2596 Check Knight Tour Configuration Medium2614 Prime In Diagonal Easy2617 Minimum Number of Visited Cells in a Grid Hard2639 Find the Width of Columns of a Grid Easy2643 Row With Maximum Ones Easy2658 Maximum Number of Fish in a Grid Medium2661 First Completely Painted Row or Column Medium2679 Sum in a Matrix Medium2684 Maximum Number of Moves in a Grid Medium2711 Difference of Number of Distinct Values on Diagonals Medium2713 Maximum Strictly Increasing Cells in a Matrix Hard2732 Find a Good Subset of the Matrix Hard2812 Find the Safest Path in a Grid Medium2850 Minimum Moves to Spread Stones Over Grid Medium2906 Construct Product Matrix Medium2923 Find Champion I Easy2931 Maximum Spending After Buying Items Hard2946 Matrix Similarity After Cyclic Shifts Easy2965 Find Missing and Repeated Values Easy3030 Find the Grid of Region Average Medium3033 Modify the Matrix Easy3044 Most Frequent Prime Medium3070 Count Submatrices with Top-Left Element and Sum Less Than k Medium3071 Minimum Operations to Write the Letter Y on a Grid Medium3122 Minimum Number of Operations to Satisfy Conditions Medium3127 Make a Square with the Same Color Easy3142 Check if Grid Satisfies Conditions Easy3148 Maximum Difference Score in a Grid Medium3195 Find the Minimum Area to Cover All Ones I Medium3197 Find the Minimum Area to Cover All Ones II Hard3212 Count Submatrices With Equal Frequency of X and Y Medium3225 Maximum Score From Grid Operations Hard3239 Minimum Number of Flips to Make Binary Grid Palindromic I Medium3240 Minimum Number of Flips to Make Binary Grid Palindromic II Medium3242 Design Neighbor Sum Service Easy3256 Maximum Value Sum by Placing Three Rooks I Hard3257 Maximum Value Sum by Placing Three Rooks II Hard3276 Select Cells in Grid With Maximum Score Hard3286 Find a Safe Walk Through a Grid Medium3311 Construct 2D Grid Matching Graph Layout Hard3332 Maximum Points Tourist Can Earn Medium3341 Find Minimum Time to Reach Last Room I Medium3342 Find Minimum Time to Reach Last Room II Medium3363 Find the Maximum Number of Fruits Collected Hard3393 Count Paths With the Given XOR Value Medium3402 Minimum Operations to Make Columns Strictly Increasing Easy3417 Zigzag Grid Traversal With Skip Easy3418 Maximum Amount of Money Robot Can Earn Medium3446 Sort Matrix by Diagonals Medium3459 Length of Longest V-Shaped Diagonal Segment Hard3462 Maximum Sum With at Most K Elements Medium3484 Design Spreadsheet Medium3529 Count Cells in Overlapping Horizontal and Vertical Substrings Medium3537 Fill a Special Grid Medium3546 Equal Sum Grid Partition I Medium3548 Equal Sum Grid Partition II Hard3552 Grid Teleportation Traversal Medium3567 Minimum Absolute Difference in Sliding Submatrix Medium3568 Minimum Moves to Clean the Classroom Medium3603 Minimum Cost Path with Alternating Directions II Medium3619 Count Islands With Total Value Divisible by K Medium