Python Solution


  • 0
    A
    class Solution(object):
        def generate(self, numRows):
            """
            :type numRows: int
            :rtype: List[List[int]]
            """
            if numRows==0: return []
            if numRows==1: return [[1]]
            
            A=[[] for i in range(numRows)]
            A[0]=[1]
            for i in range(numRows)[1:]:
                x1=[0]+A[i-1]
                x2=A[i-1]+[0]
                A[i]=[x1[j]+x2[j] for j in range(i+1)]
            return A
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.