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 49a77d2 + e69fc7b commit b8b4cb5Copy full SHA for b8b4cb5
python/118-Pascal-Triangle.py
@@ -0,0 +1,16 @@
1
+class Solution:
2
+ def generate(self, rowIndex) -> List[List[int]]:
3
+ if rowIndex == 0:
4
+ return [[1]]
5
+ else:
6
+ return self.getAllRow(rowIndex - 1)
7
+ def getAllRow(self, rowIndex):
8
9
10
+ ListPrec = self.getAllRow(rowIndex - 1)
11
+ Len = len(ListPrec[-1])
12
+ ListPrec.append([1])
13
+ for i in range(0, Len - 1):
14
+ ListPrec[-1].append(ListPrec[-2][i] + ListPrec[-2][i + 1])
15
+ ListPrec[-1].append(1)
16
+ return ListPrec
0 commit comments