Skip to content

Commit 48151fa

Browse files
committed
#118 Pascal's Triangle
1 parent af16a4a commit 48151fa

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

Array/pascals-triangle.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from itertools import pairwise
2+
from typing import List
3+
4+
class Solution:
5+
def generate(self, numRows: int) -> List[int[int]]:
6+
pascal = [[1]]
7+
8+
for i in range(numRows - 1):
9+
x = [1] + [a+b for a, b in pairwise(pascal[-1])] + [1]
10+
pascal.append(x)
11+
return pascal

0 commit comments

Comments
 (0)