Question DSA-DP-0065
HardWhat is the output of this code?
def min_path(g):
R, C = len(g), len(g[0])
d = [row[:] for row in g]
for i in range(R):
for j in range(C):
if i == 0 and j == 0: continue
d[i][j] += min(d[i - 1][j] if i else float("inf"), d[i][j - 1] if j else float("inf"))
return d[-1][-1]
print(min_path([[1, 3, 1], [1, 5, 1], [, , ]]))
- A.
6
- B.
8
- C.
Sign up free to see the answer and a step-by-step explanation.