File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -17,16 +17,16 @@ def minimum_total(triangle: list[list[int]]) -> int:
1717 >>> minimum_total([]) # doctest: +IGNORE_EXCEPTION_DETAIL
1818 Traceback (most recent call last):
1919 ValueError: triangle must be non-empty and well-formed
20- >>> minimum_total([[1],[2]]) # malformed (second row length not 2) # doctest: +IGNORE_EXCEPTION_DETAIL
20+ >>> minimum_total([[1],[2]]) # doctest: +IGNORE_EXCEPTION_DETAIL
2121 Traceback (most recent call last):
2222 ValueError: triangle must be non-empty and well-formed
2323 """
2424 # Basic validation: non-empty and proper "triangle" shape
2525 if not triangle or any (len (row ) != i + 1 for i , row in enumerate (triangle )):
2626 raise ValueError ("triangle must be non-empty and well-formed" )
2727
28- # Start from the last row and fold upwards.
29- # dp[j] will store the minimum path sum from row r to the bottom starting at column j.
28+ # Start from the last row and fold upwards. dp[j] stores the minimum path
29+ # sum from row r to the bottom starting at column j.
3030 dp = triangle [- 1 ][:] # copy so we don't mutate the input
3131
3232 for r in range (len (triangle ) - 2 , - 1 , - 1 ):
You can’t perform that action at this time.
0 commit comments