Python solution


  • 0
    O
    class Solution:
        # @param {integer} rowIndex
        # @return {integer[]}
        def getRow(self, rowIndex):
            if rowIndex<2:
                return [1]*(rowIndex+1)
            else:
                lis=[1,1]
                for i in range(2,rowIndex+1):                   
                    for j in range(0,i):
                        if j==0:
                            tmp = [1]
                        else:
                            tmp.append(lis[j-1]+lis[j])
                    tmp.append(1)
                    lis = tmp
                return lis

Log in to reply
 

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