classSolution(object):defgenerate(self, numRows):"""
:type numRows: int
:rtype: List[List[int]]
"""
ln=numRows
if ln==0:return[]
tmp=[0,1]
res=[]for i inrange(ln):
curr=[]for i inrange(len(tmp)-1):
curr.append(tmp[i]+tmp[i+1])
res.append(curr)
tmp=[0]+curr[:]+[0]return res
119. Pascal’s Triangle II
classSolution(object):defgetRow(self, rowIndex):"""
:type rowIndex: int
:rtype: List[int]
"""
ln=rowIndex
tmp=[0,1]for i inrange(ln+1):
curr=[]for i inrange(len(tmp)-1):
curr.append(tmp[i]+tmp[i+1])
tmp=[0]+curr[:]+[0]return curr