Skip to content

Commit

Permalink
submit 119. Pascal's Triangle II
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenxliu committed Jul 24, 2016
1 parent f2048d0 commit 02a062b
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions hudeven/P119.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
class Solution(object):
def getRow(self, rowIndex):
"""
:type rowIndex: int
:rtype: List[int]
"""
length = rowIndex + 2
curRow = [0] * (length)
lastRow = [0] * (length)
curRow[1] = 1
lastRow[1] = 1
for i in range(1, rowIndex + 1):
for j in range(1, i + 2):
curRow[j] = lastRow[j - 1] + lastRow[j]
print "row%d is: %s" % (i, lastRow)
lastRow = copy.copy(curRow)

return curRow[1:]

0 comments on commit 02a062b

Please sign in to comment.