Quick python solution with zip


  • 0
    M
    class Solution(object):
        def generate(self, numRows):
            """
            :type numRows: int
            :rtype: List[List[int]]
            """
            if numRows == 0:
                return []
            row = [1]
            k = [0]
            result = [row]
            for i in range(0, numRows-1):
                row = [l+r for l,r in zip(row+k, k+row)]
                result.append(row)
            return result
    
    

Log in to reply
 

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