My O(k) space Python solution


  • 2
    L
    class Solution:
        # @param {integer} rowIndex
        # @return {integer[]}
        def getRow(self, rowIndex):
            res = []
            for i in range(rowIndex+1):
                res.append(1)
                #range(start,end,step)
                for j in range(i,0,-1):
                    if j==i:
                        res[j]=1
                    else:
                        res[j] += res[j-1]
            return res

Log in to reply
 

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