class Solution(object):
def getRow(self, rowIndex):
"""
:type rowIndex: int
:rtype: List[int]
"""
last = [1]
res = [1]
for r in range(1, rowIndex + 1):
res = [1]
for index in range(len(last) - 1):
res.append(last[index] + last[index + 1])
res.append(1)
last = res
return res
if __name__ == "__main__":
s = Solution()
print s.getRow(3)
Download Pascal's Triangle II.pyLeetcode 119 Pascal's Triangle II problem solution in python3 with explanation. This is the best place to expand your knowledge and get prepared for your next interview.
Feedback is the most important part of any website.
If you have any query, suggestion or feedback, Please feel free to contact us.