algorithm notes: leetcode#119 pascal’s triangle 2

Problem


Analysis


Solution


1
2
3
4
5
6
7
8
9
10
class (object):
def getRow(self, rowIndex):
"""
:type rowIndex: int
:rtype: List[int]
"""
ans = [1]
for _ in range(rowIndex):
ans = [x+y for x, y in zip([0]+ans, ans+[0])]
return ans

119. Pascal’s Triangle II