Leetcode 118 Pascal Triangle
class Solution:
def generate(self, numRows: int) -> List[List[int]]:
res = [[1]]
for i in range(1, numRows):
row = [1] + [res[-1][j-1] + res[-1][j] for j in range(1,i)] + [1]
res.append(row)
return res
Last posted
Total of 3 posts
Leetcode 118 Pascal Triangle
class Solution:
def generate(self, numRows: int) -> List[List[int]]:
res = [[1]]
for i in range(1, numRows):
row = [1] + [res[-1][j-1] + res[-1][j] for j in range(1,i)] + [1]
res.append(row)
return res
Be Civil — "Be curious, not judgemental"
All contents are responsibility of its posters.