Description
Solutions
Rotate Matrix
🤘 INTERN📚RELATED PROBLEMS
You are given a matrix of N*M size. Write an algorithm to rotate the matrix by 90 degrees.
Input
The first line of input consists of two integer- inputMat_row
and inputMat_col
, representing the number of row (N) and column (M) of the matrix.
The next M lines consist of N space-separated integers representing the elements of the matrix.
Output
Print the matrix after rotating it by 90 degrees.
Note
Number of rows (N) and number of columns (M) will always be same.
ᡣ𐭩 •Credit to Charlotte。ꪆৎ ˚⋅
Example 1:
Input: matrix = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
Output: [[7, 4, 1], [8, 5, 2], [9, 6, 3]]
Explanation:We have to rotate the given matrix by 90 degrees, so we will rotate each and every element of the matrix in clockwise direction, and we get "7 4 1", "8 5 2", "9 6 3" in each row.
Constraints:
🍉🍉

Related Problems
Testcase
Result
Case 1
input:
output: