Back to all patterns

Matrix Manipulation

2 problems • Practice on LeetCode to earn credits

About This Pattern

Master the Matrix Manipulation pattern by practicing these problems organized by difficulty.Focus on the Key Signals - these are the indicators that tell you when to use this pattern.

Medium (2)

Rotate Image

Rotate n×n 2D matrix 90 degrees clockwise in-place.

Key Signals:

Transpose then reverse rowsOr layer by layer rotationIn-place swaps
Set Matrix Zeroes

Set entire row and column to 0 if element is 0, in-place with O(1) space.

Key Signals:

Use first row/col as markersTwo-pass approachHandle first row/col separately