easy python solution 100%


  • 0
    E
    def generate(self, numRows):
        if numRows==0:
            return []
        res=[[1],]
        for i in range(0,numRows-1):
            l=[sum(p) for p in list(zip(res[i],res[i][1:]))]
            l.insert(0,1)
            l.append(1)
            res.append(l)
        return res

  • 0
    E

    oh~~~~ I found using collections.deque would be better


Log in to reply
 

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