Skip to content

Commit 7153e4f

Browse files
authored
Create Pascal's Triangle.py
In Pascal's triangle, each number is the sum of the two numbers directly above it.
1 parent f13c68c commit 7153e4f

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

Pascal's Triangle.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
class Solution(object):
2+
def getRow(self, rowIndex):
3+
"""
4+
:type rowIndex: int
5+
:rtype: List[int]
6+
"""
7+
row = [1]
8+
for i in range(rowIndex):
9+
for j in range(i):
10+
row[j] += row[j+1]
11+
row = [1] + row
12+
return row
13+
14+

0 commit comments

Comments
 (0)