1. 程式人生 > >leetcode python  118.楊輝三角 119.楊輝三角 II

leetcode python  118.楊輝三角 119.楊輝三角 II

class Solution(object):
    def generate(self, numRows):
        L = []
        if numRows == 0:
            return L
        for i in range(numRows):
            L.append([1])
            for j in range(1,i+1):
                if j==i:
                    L[i].append(1)
                else:
                    L[i].append(L[i-1
][j]+L[i-1][j-1]) return L