class Solution: # @return a list of integers def nCk(self,n,k): if n*k==0 or n<0 or k<0: return 1 rst=1 step=1 for i in range(k+1,n+1): rst=rst*i//step step+=1 return rst def getRow(self, rowIndex): return [self.nCk(rowIndex,i) for i in range(rowIndex+1)] if rowIndex>=0 else []
Tuesday, September 9, 2014
Leetcode: Pascal's Triangle II @Python
Subscribe to:
Post Comments
(
Atom
)
No comments :
Post a Comment