Skip to content

Commit dab1db8

Browse files
committed
day-9
1 parent 51afeff commit dab1db8

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

reshape-the-matrix.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
class Solution:
2+
def matrixReshape(self, nums: List[List[int]], r: int, c: int) -> List[List[int]]:
3+
myList = [x for row in nums for x in row ]
4+
5+
if r * c == len(myList):
6+
return [myList[i*c:(i+1)*c] for i in range(r)]
7+
else:
8+
return nums

0 commit comments

Comments
 (0)