← DSADSA 7.2

Matrix Manipulation

Not started yet — 5 problems queued.

Treat the matrix as coordinates. Common tricks: transpose-then-reverse for rotation, layer-by-layer peeling for spiral traversal, row/column flags for zeroing in place.

Sub-patterns

  • A — Rotation. Transpose-then-reverse to rotate in place.
  • B — Spiral Traversal. Layer-by-layer peeling from the outside in.
  • C — Search in a Sorted Matrix. Exploit row- and column-sorted order.
  • D — In-Place Marking. Row/column flags to mark cells without extra space.

Practice set (5)

  • Medium — Rotate Image, Spiral Matrix, Set Matrix Zeroes, Search a 2D Matrix II, Game of Life

Notes from readers

Comments — via GitHub