class Solution(object):
def getNextRow(self, rows):
if len(rows) == 0:
return [1]
prevRow = rows[-1]
newRow = [prevRow[i]+prevRow[i+1] for i in range(0, len(prevRow)-1)]
# newRow = []
# for i in range(0, len(prevRow)-1):
# newRow.append( prevRow[i]+prevRow[i + 1])
return [1] + newRow + [1]
def generate(self, numRows):
"""
:type numRows: int
:rtype: List[List[int]]
"""
result = []
for i in range(0, numRows):
nextRow = self.getNextRow(result)
result.append(nextRow)
return result