Matrices mind map

2-D grids, traversal, and matrix manipulation.

Core idea: Make coordinates explicit: bounds, neighbors, visited state, and direction.

Mnemonic: Coordinate → bound → visit · Cost: O(rows × cols) typical

Walk: Direction & boundaries

Signal: Traversal follows layers, diagonals, or turns at an edge.

Move: Encode direction deltas and shrink boundaries or rotate direction when blocked.

Examples: Spiral Matrix, Diagonal Traverse, Robot Simulation

Connect: Flood fill

Signal: Cells form components through allowed neighbor moves.

Move: Start at each unseen cell, mark on entry, and explore every valid neighbor once.

Examples: Number of Islands, Max Area of Island, Flood Fill

Transform: Markers, order & index math

Signal: The matrix changes in place or sorted rows/columns can discard search space.

Move: Reuse boundary markers, transpose + reverse, or start at a corner that eliminates a line.

Examples: Set Matrix Zeroes, Rotate Image, Search 2D Matrix

Explore: Path state

Signal: The answer depends on moves through the grid and possibly prior choices.

Move: Use DP for acyclic moves; use memoized DFS or backtracking when choices branch.

Examples: Unique Paths, Longest Increasing Path, Word Search

Every mind map