MCPcopy Create free account
hub / github.com/HuberTRoy/leetCode / minimumTotal

Method minimumTotal

Array/Triangle.py:32–46  ·  view source on GitHub ↗

:type triangle: List[List[int]] :rtype: int

(self, triangle)

Source from the content-addressed store, hash-verified

30"""
31class Solution(object):
32 def minimumTotal(self, triangle):
33 """
34 :type triangle: List[List[int]]
35 :rtype: int
36 """
37
38 for i in range(len(triangle)-2, -1, -1):
39 length = len(triangle[i])
40 for j in range(length):
41
42 _right = triangle[i+1][j+1]
43 _self = triangle[i+1][j]
44 mins = min(_right, _self)
45 triangle[i][j] += mins
46 return min(triangle[0])

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected