A few extra lines but very readable. Can someone help me calculate and/or prove the time and space complexity! Thanks

```
def matrix(nums,r,c):
if r*c != len(nums)*len(nums[0]):
return nums
else:
array = []
for i in range(len(nums)):
for j in range(len(nums[0])):
array.append(nums[i][j])
#all elements will be added to array
matrix = []
while len(array) != 0:
matrix.append(array[:c])
array = array[c::]
return matrix
#elements are spliced into lists and appended to matrix
```