MCPcopy Create free account
hub / github.com/codemistic/Data-Structures-and-Algorithms / dfs

Function dfs

Python/minimum_path_sum.py:8–16  ·  view source on GitHub ↗
(r, c)

Source from the content-addressed store, hash-verified

6
7 @cache
8 def dfs(r, c):
9 if r == nR - 1 and c == nC - 1:
10 return grid[r][c]
11 paths = []
12 for a, b in adj:
13 r2, c2 = r + a, c + b
14 if 0 <= r2 < nR and 0 <= c2 < nC:
15 paths.append(dfs(r2, c2))
16 return grid[r][c] + min(paths)
17 return dfs(0, 0)

Callers 1

minPathSumFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected