Intuitive PYTHON


  • 0
    V
    class Solution(object):
        def getRow(self, rowIndex):
            """
            :type rowIndex: int
            :rtype: List[int]
            """
            k = 0
            currRow = []
            while k < rowIndex + 1:
                nextRow = []
                for pos in xrange(k+1):
                    if pos == 0 or pos == k:
                        nextRow.append(1)
                    else:
                        nextRow.append(currRow[pos - 1] + currRow[pos])
                currRow = nextRow
                k += 1
            
            return currRow
    

Log in to reply
 

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