my python3 Solution


  • 0
    Y
    class Solution(object):
        def getRow(self, rowIndex):
            """
            :type rowIndex: int
            :rtype: List[int]
            """
            if rowIndex == 0:
                return [1]
            if rowIndex == 1:
                return [1, 1]
            pre = [1, 1]
            for line_num in range(2, rowIndex+1):
                cur = [1]
                for index, item in enumerate(pre):
                    if index == 0:
                        continue
                    else:
                        cur.append(pre[index-1] + pre[index])
                cur.append(1)
                pre = cur
            return cur
    

Log in to reply
 

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