class Solution(object):
def getRow(self, rowIndex):
"""
:type rowIndex: int
:rtype: List[int]
"""
res = [1]
for i in range(1, rowIndex + 1):
res.insert(0, 0)
# j循环每次算出r[0]...r[j-1],再加上最后一个永远存在的1,正好是rowIndex+1个数
for j in range(i):
res[j] = res[j] + res[j + 1]
return res
来源:CSDN
作者:请叫我算术嘉
链接:https://blog.csdn.net/ssjdoudou/article/details/103749050