We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 9b6ce8e commit 85c5877Copy full SHA for 85c5877
pythonProblems/rotateMatrix/rotateMatrix.py
@@ -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