MCPcopy Create free account
hub / github.com/TheAlgorithms/Python / fill_row

Function fill_row

graphs/minimum_path_sum.py:47–57  ·  view source on GitHub ↗

>>> fill_row([2, 2, 2], [1, 2, 3]) [3, 4, 5]

(current_row: list, row_above: list)

Source from the content-addressed store, hash-verified

45
46
47def fill_row(current_row: list, row_above: list) -> list:
48 """
49 >>> fill_row([2, 2, 2], [1, 2, 3])
50 [3, 4, 5]
51 """
52
53 current_row[0] += row_above[0]
54 for cell_n in range(1, len(current_row)):
55 current_row[cell_n] += min(current_row[cell_n - 1], row_above[cell_n])
56
57 return current_row
58
59
60if __name__ == "__main__":

Callers 1

min_path_sumFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected