Lesson

Matrices & Grids

2D arrays as graphs — islands, paths, and in-place rotations.

Medium → HardTime O(mn)Space O(mn)
Practice problems
Loading visualization…

Loading solution…

Grid as graph

Each cell is a node; edges go to valid neighbors. BFS/DFS/Union-Find all apply.

Pitfalls

  • !Row/col swap bugs
  • !Mutating input unexpectedly
  • !Boundary checks

Practice from this topic

Showing 24 of the related problems in the 1000-question bank.

View all →

Got the lesson?

Mark Matrices & Grids as understood when the ideas stick.