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]
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章