Skip to content

Commit

Permalink
Update 119-Pascal-Triangle-II.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Vitali-Matteo authored Aug 22, 2022
1 parent cba335b commit 0fdb30e
Showing 1 changed file with 5 additions and 18 deletions.
23 changes: 5 additions & 18 deletions python/119-Pascal-Triangle-II.py
Original file line number Diff line number Diff line change
@@ -1,28 +1,15 @@
class Solution:

Memo = {}

def getRow(self, rowIndex: int) -> List[int]:

if rowIndex in self.Memo:

class Solution:
Memo = {}
def getRow(self, rowIndex: int) -> List[int]:
if rowIndex in self.Memo:
return self.Memo[rowIndex]

if rowIndex == 0:

return [1]

ListPrec = self.getRow(rowIndex - 1)

Result = [1]

for i in range(0, len(ListPrec) - 1):

Result.append(ListPrec[i] + ListPrec[i + 1])

Result.append(1)

Result.append(1)
self.Memo[rowIndex] = Result

return Result

0 comments on commit 0fdb30e

Please sign in to comment.