Skip to content

Commit 406093f

Browse files
committed
day-5
1 parent 541065d commit 406093f

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

pascals-triangle.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
class Solution:
2+
def generate(self, numRows: int) -> List[List[int]]:
3+
result = []
4+
5+
for row_num in range(numRows):
6+
row = [None for _ in range(row_num+1)]
7+
row[0], row[-1] = 1, 1
8+
for j in range(1, len(row)-1):
9+
row[j] = result[row_num-1][j-1] + result[row_num-1][j]
10+
result.append(row)
11+
return result
12+

0 commit comments

Comments
 (0)