Z35
Network Delay Time (Dijkstra)
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) -> intInput & 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 <= 100Example 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: 2Example Test Scenarios (3)
Example 1
Input:
[[[2,1,1],[2,3,1],[3,4,1]],4,2]Expected Output:
2Example 2: Tek Kenar
Input:
[[[1,2,1]],2,1]Expected Output:
1Example 3: Ulaşılamaz
Input:
[[[1,2,1]],2,2]Expected Output:
-1