Interview Query

Matrix Rotation

Start Timer

0:00:00

Upvote
10
Downvote
Save question
Mark as completed
View comments (15)
Next question

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]] )

array

12345
23456
34567
45678
56789

Output:

54321
65432
76543
87654
98765

.
.
.
.
.


Comments

Loading comments