Pascal's Triangle II
Question
Example:
Answer
solution:this is done by myself.
class Solution(object):
def getRow(self, rowIndex):
"""
:type rowIndex: int
:rtype: List[int]
"""
result = []
for i in xrange(rowIndex+1):
result.append([])
for j in xrange(i + 1):
if j in (0, i):
result[i].append(1)
else:
result[i].append(result[i - 1][j - 1] + result[i - 1][j])
return result[rowIndex]Knowledge:
Last updated