执行用时:52 ms, 在所有 Python3 提交中击败了6.34%的用户
内存消耗:14.8 MB, 在所有 Python3 提交中击败了73.25%的用户
class Solution:
def generate(self, numRows: int) -> List[List[int]]:
res=[]
if numRows==1:
return [[1]]
res.append([1])
for i in range(1,numRows):
tmp=[1]
for j in range(1,i):
tmp.append(res[-1][j-1]+res[-1][j])
tmp.append(1)
res.append(tmp)
return res