Clean JavaScript Bellman-Ford solution
Introduction to Bellman-Ford https://www.youtube.com/watch?v=obWXjtg0L64\n\n\nconst networkDelayTime = (times, N, K) => {\n  const time = Array(N + 1).fill(Infi
Introduction to Bellman-Ford https://www.youtube.com/watch?v=obWXjtg0L64\n\n```\nconst networkDelayTime = (times, N, K) => {\n  const time = Array(N + 1).fill(Infinity);\n  time[K] = 0;\n  for (let i = 0; i < N; i++) {\n    for (const [u, v, t] of times) {\n      if (time[u] === Infinity) continue;\n      if (time[v] > time[u] + t) {\n        time[v] = time[u] + t;\n      }\n    }\n  }\n\n  let res = 0;\n  for (let i = 1; i <= N; i++) {\n    res = Math.max(res, time[i]);\n  }\n  return res === Infinity ? -1 : res;\n};\n```\n
['JavaScript']