首页 > 代码库 > 119. Pascal's Triangle II

119. Pascal's Triangle II

Given an index k, return the kth row of the Pascal‘s triangle.

For example, given k = 3,
Return [1,3,3,1].

 自己写的~~

 1 class Solution(object):
 2     def getRow(self, rowIndex):
 3         """
 4         :type rowIndex: int
 5         :rtype: List[int]
 6         """
 7         
 8         res=[[1]]
 9         for i in range(1,rowIndex+1):
10             res += [map(lambda x,y: x+y, res[-1]+[0], [0]+res[-1])]
11         return res[rowIndex]

for i in range(1,2): i 只能取到1

119. Pascal's Triangle II