class Solution(object):
def generate(self, numRows):
"""
:type numRows: int
:rtype: List[List[int]]
"""
n = numRows
arr = []
for i in range(n):
arr.append([])
for j in range(i+1):
arr[i].append(1)
for i in range(2, n):
for j in range(1, i):
arr[i][j] = arr[i-1][j-1]+arr[i-1][j]
return (arr)
118. 杨辉三角(LeetCode-力扣-Python)
最新推荐文章于 2024-10-31 16:16:13 发布