Matrix
Traverse and transform 2D grids in place using index math for rows, columns, layers, and diagonals.
- • In-place rotation or transposition
- • Spiral, diagonal, or layer traversal
- • Marking cells without extra space
- • Coordinate index arithmetic
- • The grid is really a graph (use BFS/DFS)
- • Cells have overlapping subproblems (use DP)
- • Mixing up row and column indices
- • Mutating cells you still need to read
- • Boundary handling on the last layer
Key Invariant
Treat the grid as coordinates — most moves are arithmetic on (row, col), often handled layer by layer