← All problems

Rotate Image (90 degrees in place)

Medium matrixarrays LeetCode ↗
Rotate an n x n matrix 90 degrees clockwise in place, using O(1) extra space. Find the two-step decomposition that makes this easy.

Hints (0/3 revealed)

Log in to reveal hints progressively.

Complexity

Time O(n^2), Space O(1)

Common pitfalls

  • Extra matrix (violates in-place)
  • Counterclockwise by mistake

Your solution

Log in to save your code and track progress.