A simple Python solution (29ms)


  • 0
    C

    runtime beats 99.13% of python submissions

    class Solution(object):
        def getRow(self, rowIndex):
            """
            :type rowIndex: int
            :rtype: List[int]
            """
            a = [1]
            b = []
            for i in range(0,rowIndex):
                b = [1] + [ a[j-1]+a[j] for j in range(1,i+1)] + [1]
                a=b
            return a
    

Log in to reply
 

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