My accept code for Pascal's Triangle II, changing the last line would do to Pascal's Triangle I


  • 0
    M
    class Solution:
    # @return a list of integers
    def getRow(self, rowIndex):
        s = []
        for i in range(rowIndex+1):
            s.append([])
            for j in range(i+1):
                if j == 0 or i == 0:
                    s[i].append(1)
                elif j == i:
                    s[i].append(1)
                else:
                    s[i].append(s[i-1][j-1]+s[i-1][j])
        return s[rowIndex]

Log in to reply
 

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