Rotate a matrix 90° clockwiseSee transpose + reverse happen cell by cell.
This visualizer shows the classic in‑place solution: first transpose the matrix, then reverse each row. Watch each swap and row reversal, and track exactly how the original matrix transforms into the rotated one.
Demo: 3 × 3 matrixO(n²) time · O(1) space
1
2
3
4
5
6
7
8
9
Animation shows transpose swaps, then row reversals, then final rotated matrix.
SETUP Phase
TRANSPOSE Phase
REVERSE Phase
FINAL Phase
Matrix size: 3 × 3Step 1 / 15
1
2
3
4
5
6
7
8
9
#
Initial matrix. Goal: rotate 90° clockwise using transpose + reverse.
Speed700ms
Progress1/15
Key idea
1) Transpose across the main diagonal. 2) Reverse every row. That combination is exactly a 90° clockwise rotation.
A common interview question: implement this in‑place, without extra matrices.