Dsa
Matrix
Easy
Rotate Matrix by 90 Degrees
Write a function that rotates an n x n matrix 90 degrees clockwise in place.
The input is given as:
- The first line contains an integer n (1 ≤ n ≤ 100).
- The next n lines contain n integers each representing the matrix elements.
Output the rotated matrix in the same format.
Example:
Input:
3
1 2 3
4 5 6
7 8 9
Output:
7 4 1
8 5 2
9 6 3
Key concepts
matrixrotationin-placetransformation
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now