You are given an n x n 2D matrix representing an image, rotate the image by 90 degrees (clockwise) in-place.
You are given an `n x n` 2D matrix representing an image, rotate the image by 90 degrees (clockwise). You have to rotate the image in-place, which means you have to modify the input 2D matrix directly.
Invariant: Transposition swaps across main diagonal; horizontal reversal rotates clockwise.
Decompose spatial matrix rotations into symmetrical operations: transpose + reflection.
Bottleneck: Matrix element swaps.
You are given an n x n 2D matrix representing an image, rotate the image by 90 degrees (clockwise) in-place.
You are given an `n x n` 2D matrix representing an image, rotate the image by 90 degrees (clockwise). You have to rotate the image in-place, which means you have to modify the input 2D matrix directly.
Invariant: Transposition swaps across main diagonal; horizontal reversal rotates clockwise.
Decompose spatial matrix rotations into symmetrical operations: transpose + reflection.
Bottleneck: Matrix element swaps.
Initialized 3x3 Matrix. Step 1 will transpose across the main diagonal; Step 2 will reverse each row horizontally.