Optimal Algorithmic Approach
Transpose + Row-Reverse. Both steps are O(n²) and in-place.
Core Invariants & Edge Cases
- Step 1: Transpose the matrix (swap matrix[i][j] with matrix[j][i])
- Step 2: Reverse each row
- These two steps compose to a 90° clockwise rotation