119.Pascal's Triangle II

 

 

class Solution:
    def getRow(self, rowIndex: int) -> List[int]:
        ans = [1]
        for i in range(rowIndex + 1):
            tmp = [1 for i in range(i + 1)]
            for j in range(1, i):
                tmp[j] = ans[j-1] + ans[j]
            ans = tmp
        return ans

 

posted @ 2020-05-09 14:38  星海寻梦233  阅读(63)  评论(0编辑  收藏  举报