新年好呀!
代码:
class Solution:
def construct2DArray(self, original: List[int], m: int, n: int) -> List[List[int]]:
if len(original) != m * n:
return []
ans = [[0] * n for _ in range(m)]
for i in range(len(original)):
r = i // n
c = i % n
ans[r][c] = original[i]
return ans