Why this doesn't work?


  • 0
    S

    class Solution(object):

    def generate(self, numRows):
        """
        :type numRows: int
        :rtype: List[List[int]]
        """
        if numRows==0:
            return [[]]
        elif numRows==1:
            return [[1]]
        elif numRows==2:
            return [[1],[1,1]]
        else:
            return (self.generate(numRows-1)).append(self.nextline(self.generate(numRows-1)))
    
    def nextline(self,listOflist):
        result=[1]
        for i in range(len(listOflist[-1])-1):
            result.append(listOflist[-1][i]+listOflist[-1][i+1])
        result.append(1)
        return result

Log in to reply
 

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