my python solution


  • 0
    B

    '''
    class Solution(object):
    def getRow(self, rowIndex):
    """
    :type rowIndex: int
    :rtype: List[int]
    """

        res = []
        n = rowIndex+1
        halfN = n/2 +1 if n%2 ==1 else n/2
        tp = []
        for i in range(n):
            tp.append(1)
        
        for i in range(halfN):
            s = 0
            for j in range(len(tp)-1):
                s += tp[j]
                tp[j] =s
            # print tp
            res.append(tp.pop())
        
        # print res
        
        res.extend(res[::-1]) if n%2 ==0 else res.extend(res[-2::-1]) 
        return res
    

    '''


Log in to reply
 

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