Question: https://oj.leetcode.com/problems/pascals-triangle/

Question Name: Pascal’s Triangle

1 2 3 4 5 6 7 8 9 10 11 12 | class Solution: # @return a list of lists of integers def generate(self, numRows): if numRows == 0: return [] result = [[1]] while len(result) < numRows: temp = [1] # Every row starts with 1 for index in xrange(len(result[-1])-1): temp.append(result[-1][index] + result[-1][index+1]) temp.append(1) # Every row ends with 1 result.append(temp) return result |