class Solution(object):
def generate(self, numRows):
"""
:type numRows: int
:rtype: List[List[int]]
"""
if numRows == 0:
return []
if numRows == 1:
return [[1]]
L = [[1]]
for i in range(1,numRows):
a = []
a.append(L[i-1][0])
for j in range(len(L[i-1]) - 1):
a.append(L[i-1][j] + L[i-1][j+1])
a.append(L[i-1][len(L[i-1]) - 1])
L.append(a)
return L
leetcode - 118 - 杨辉三角
最新推荐文章于 2021-09-21 11:32:26 发布