# Pascal's Triangle
# https://leetcode.com/problems/pascals-triangle/
"""Given numRows, generate the first numRows of Pascal's triangle.
For example, given numRows = 5,
Return
[
[1], #1
[1,1], #2
[1,2,1], #3
[1,3,3,1], #4
[1,4,6,4,1] #5
]"""
class Solution:
# @param {integer} numRows
# @return {integer[][]}
def generate(self, numRows):
PT = []
if numRows == 1:
PT = [[1]]
elif numRows == 2:
PT = [[1],[1,1]]
elif numRows > 2:
PT =[[1],[1,1]]
n = 1
while n < numRows - 1:
PT += [[1]]
for x in range(n):
PT[-1].append(PT[-2][x]+PT[-2][x+1])
PT[-1].append(1)
n += 1
return PT