118. Pascal's Triangle
class Solution:
def generate(self, numRows: int) -> List[List[int]]:
def helper(numRows):
if numRows == 1:
res.append([1])
return [1]
prev = helper(numRows - 1)
curr = []
for i in range(len(prev) - 1):
curr.append(prev[i] + prev[i+1])
res.append([1] + curr + [1])
return [1] + curr + [1]
res = []
helper(numRows)
return res