Pascal's Triangle
[
[1],
[1,1],
[1,2,1],
[1,3,3,1],
[1,4,6,4,1]
]class Solution(object):
def generate(self, numRows):
"""
:type numRows: int
:rtype: List[List[int]]
"""
result = [[1]*(i+1) for i in xrange(numRows)]
for i in xrange(1, numRows):
for j in xrange(1, i):
result[i][j] = result[i-1][j-1] + result[i-1][j]
return resultLast updated