Skip to content

Matrix Problems

Matrix problems involve 2D grids — traversals, rotations, spiral orders, and path-finding. Many combine with DFS/BFS for island counting, flood fill, and shortest path in a grid.

21 problems

Title Difficulty
As Far from Land as Possible Medium
Count Square Submatrices with All Ones Medium
Distance to the Nearest 1 Medium
Game of Life Medium
Capture Surrounded Regions Medium
Largest Rectangle with Equal Zeros and Ones Hard
Maximal Rectangle Hard
Maximal Square Medium
Largest All-Ones Rectangle Medium
Minimum Path Sum Medium
Number of Islands Medium
2D Range Sum Queries Medium
All Paths Through a Maze Medium
Rotate Image Medium
Rotting Oranges Medium
Set Matrix Zeroes Medium
Snakes and Ladders Medium
Spiral Matrix Medium
Minimum Knight Moves on a Board Medium
Sudoku Solver Hard
Count Spanning Trees Hard