Matrix / Grid
Grid problems treat a 2-D matrix as a graph of cells and apply traversal, search, or DP across the rows and columns. Watch for boundary checks, in-place marking to save space, and the four- versus eight-direction neighbor choice.
8 LeetCode problems solved with the Matrix / Grid pattern. Practice them with spaced repetition so the pattern sticks.
- Game of LifeMEDIUM · O(m * n)
- Island PerimeterEASY · O(m*n)
- Rotate ImageMEDIUM · O(n^2)
- Search a 2D Matrix IIMEDIUM · O(m + n)
- Set Matrix ZeroesMEDIUM · O(m*n)
- Spiral MatrixMEDIUM · O(m*n)
- Spiral Matrix IIMEDIUM · O(n^2)
- Transpose MatrixEASY · O(m*n)
See the full solution
The complete approach, reference solutions in 5 languages, and a step-by-step visualization — then add this problem to your spaced-repetition schedule.
Start free →