Z35

Network Delay Time (Dijkstra)

Staff / Principal Engineer
Target Time: 40 - 50 Minutes
Type: NUMERIC

Problem Statement & Objective

You are given a network of n nodes labeled from 1 to n. Return the minimum time it takes for all the n nodes to receive a signal sent from node k.

Function Signature (Python)

network_delay_time(times: list[list[int]], n: int, k: int) -> int

Input & Output Contract

Output Rule:Tüm düğümlere ulaşma süresi veya -1.

System Constraints

1 <= k <= n <= 100
1 <= zamanlar.length <= 6000
1 <= w <= 100

Example Execution Walkthrough

zamanlar = [[2, 1, 1], [2, 3, 1], [3, 4, 1]], n = 4, k = 2 -> 2'den 4'e 2 birim sürede ulaşılır -> cevap: 2

Example Test Scenarios (3)

Example 1
Input:[[[2,1,1],[2,3,1],[3,4,1]],4,2]
Expected Output:2
Example 2: Tek Kenar
Input:[[[1,2,1]],2,1]
Expected Output:1
Example 3: Ulaşılamaz
Input:[[[1,2,1]],2,2]
Expected Output:-1
Loading Python Editor...
Input Parameters
[
  [
    [
      2,
      1,
      1
    ],
    [
      2,
      3,
      1
    ],
    [
      3,
      4,
      1
    ]
  ],
  4,
  2
]
Expected Output
2