Skip to content

Commit 0fdb30e

Browse files
Update 119-Pascal-Triangle-II.py
1 parent cba335b commit 0fdb30e

File tree

1 file changed

+5
-18
lines changed

1 file changed

+5
-18
lines changed

python/119-Pascal-Triangle-II.py

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,15 @@
1-
class Solution:
2-
3-
Memo = {}
4-
5-
def getRow(self, rowIndex: int) -> List[int]:
6-
7-
if rowIndex in self.Memo:
8-
1+
class Solution:
2+
Memo = {}
3+
def getRow(self, rowIndex: int) -> List[int]:
4+
if rowIndex in self.Memo:
95
return self.Memo[rowIndex]
10-
116
if rowIndex == 0:
12-
137
return [1]
14-
158
ListPrec = self.getRow(rowIndex - 1)
16-
179
Result = [1]
18-
1910
for i in range(0, len(ListPrec) - 1):
20-
2111
Result.append(ListPrec[i] + ListPrec[i + 1])
22-
23-
Result.append(1)
24-
12+
Result.append(1)
2513
self.Memo[rowIndex] = Result
26-
2714
return Result
2815

0 commit comments

Comments
 (0)