Skip to content

Commit 85c5877

Browse files
committed
[main] added rotate matrix problem
1 parent 9b6ce8e commit 85c5877

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
from typing import List
2+
import numpy as np
3+
4+
5+
def rotate_transform(lst: List[List[int]], num: int) -> List[List[int]]:
6+
"""
7+
Rotates a 2d matrix `num` times
8+
9+
Args:
10+
lst (List[List[int]]): The 2d matrix
11+
num (int): The # of times to rotate the matrix
12+
13+
Returns:
14+
List[List[int]]: The rotated matrix
15+
"""
16+
np_arr = np.array(lst)
17+
np_arr = np.rot90(np_arr, num * -1)
18+
return np_arr.tolist()
19+
20+
21+
if __name__ == "__main__":
22+
times = 1
23+
array = [[2, 4], [0, 0]]
24+
print(rotate_transform(array, times))

0 commit comments

Comments
 (0)