Given a two-dimensional array named matrix, transform it by rotating every entry 90 degrees to the right.
Requirements:
O(1) additional memory.matrix is guaranteed to be a square N x N matrix.N, which is the matrix dimension.N lines lists N integers that form one row of the matrix.N rows, with spaces separating the N values on each row.1 <= N <= 200Input
3
2 4 6
8 10 12
14 16 18
Output
14 8 2
16 10 4
18 12 6
matrix = [[2, 4, 6], [8, 10, 12], [14, 16, 18]]14 8 2 16 10 4 18 12 6
We start with a 3x3 matrix.
The bottom row becomes the leftmost column, producing a clockwise quarter-turn.
Input
1
42
Output
42
A matrix containing one element remains unchanged after rotation.
matrix = [[2, 4, 6], [8, 10, 12], [14, 16, 18]]14 8 2 16 10 4 18 12 6
We start with a 3x3 matrix.