Interview Query

Matrix Rotation

0
Have you seen this question before?

Given an array filled with random values, write a function rotate_matrix to rotate the array by 90 degrees in the clockwise direction.

Example:

Input:

import numpy as np

array = np.array( [[1, 2, 3, 4, 5], [2, 3, 4, 5, 6], [3, 4, 5, 6, 7], [4, 5, 6, 7, 8], [5, 6, 7, 8, 9]] )

Note: matrix input and output are numpy arrays.

array

12345
23456
34567
45678
56789

Output:

54321
65432
76543
87654
98765

Next question: Monthly Product Sales
.....
Python 3.9.6
Loading editor
Use Shift + Enter to run code