title:
Given a non-negative index k where k ≤ 33, return the kth index row of the Pascal's triangle.
Note that the row index starts from 0.
Input: 3 Output: [1,3,3,1] code: class Solution(object): def getRow(self, rowIndex): """ :type rowIndex: int :rtype: List[int] """ row = [1] for i in range(1, rowIndex + 1): row = [1] + [ row[x] + row[x - 1] for x in range(1, i)] + [1] return row笔记:主要计算除去最前面和最后面的[1],其他的其实就是上一行的依次两两相加.