Question bank › Matrix
Dsa Matrix Easy

Matrix Rotation 90 Degrees

Rotate a square matrix 90 degrees clockwise in place. The matrix will always be N x N in size. Input Format: The first line contains an integer N, the number of rows (and columns). The next N lines each contain N integers representing the elements of the matrix. Output Format: Print the rotated matrix, where each row is on a new line with space-separated integers. 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-place

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
Part of InterviewLab's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.