题干如下:
import numpy as np
class Solution:
def matrixReshape(self, nums: List[List[int]], r: int, c: int) -> List[List[int]]:
a=np.array(nums)
try:
return a.reshape(r,c)
except:
return nums
直接用numpy 做的,一顿操作猛如虎,一看成绩
哎,晚上看官方题解提升一下自己吧