Problem :

https://leetcode.com/problems/pascals-triangle/description/


My Solution :

class Solution:
def generate(self, numRows):
"""
:type numRows: int
:rtype: List[List[int]]
"""
ans = []
for i in range(1, numRows+1):
row = [1]
for j in range(1, i):
row.append(sum(ans[i-2][j-1:j+1]))
ans.append(row)
return ans