Skip to content

Commit 8f93961

Browse files
Update triangle.py
1 parent e74bef6 commit 8f93961

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

dynamic_programming/triangle.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff 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):

0 commit comments

Comments
 (0)