119. 杨辉三角 II

class Solution:
    def getRow(self, rowIndex):
        """
        :type rowIndex: int
        :rtype: List[int]
        """
        ans = []
        for i in range(rowIndex+1):
            temp = [1]*(i+1)
            ans.append(temp)
            for j in range(1,i):
                ans[i][j] = ans[i-1][j-1]+ans[i-1][j]
        return ans[rowIndex]

相关文章: