class Solution:
def getRow(self, rowIndex: int) -> List[int]:
rowIndex += 1
re_pot = [[0]*i for i in range(1, rowIndex + 1)]
for i in range(rowIndex):
re_pot[i][0], re_pot[i][-1] = 1, 1
if rowIndex <= 2:
return re_pot[-1]
for i in range(2, rowIndex):
for j in range(1, i + 1):
if re_pot[i][j]:
continue
else:
re_pot[i][j] = re_pot[i - 1][j] + re_pot[i - 1][j - 1]
return re_pot[-1]
leetcode杨辉三角2(python3
最新推荐文章于 2024-09-04 15:29:39 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)