299. Rotate Matrix 90° Clockwise
MediumMatrix
Rotate the n×n matrix 90 degrees clockwise and print it.
Input format
Line 1: n n Next n lines: n integers
Output format
The rotated matrix.
Example 1
Input
3 3 1 2 3 4 5 6 7 8 9
Output
7 4 1 8 5 2 9 6 3
Example 2
Input
1 1 5
Output
5
Constraints
1 ≤ n ≤ 500
Read input from standard input and print the answer to standard output. Your code is judged against 5 test cases, most of them hidden.
Loading the MyLoginn IDE…