Thanks to visit codestin.com Credit goes to github.com
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 76d362a + fda79c0 commit f6a6027Copy full SHA for f6a6027
python/118-Pascals-Triangle.py
@@ -0,0 +1,10 @@
1
+class Solution:
2
+ def generate(self, numRows: int) -> List[List[int]]:
3
+ triangle = []
4
+ for row_num in range(numRows):
5
+ row = [None for _ in range(row_num + 1)]
6
+ row[0], row[-1] = 1, 1
7
+ for j in range(1, row_num):
8
+ row[j] = triangle[row_num - 1][j-1] + triangle[row_num - 1][j]
9
+ triangle.append(row)
10
+ return triangle
0 commit comments