Leetcode-cn.com 2021-08-02
🟡 743.network-delay-time
🏷️ Tags
#depth_first_search #breadth_first_search #graph #shortest_path #heap_priority_queue
Description
有
给你一个列表
现在,从某个节点
Example
🟡 743.network-delay-time
🏷️ Tags
#depth_first_search #breadth_first_search #graph #shortest_path #heap_priority_queue
Description
有
n 个网络节点,标记为 1 到 n。给你一个列表
times,表示信号经过 有向 边的传递时间。 times[i] = (ui, vi, wi),其中 ui 是源节点,vi 是目标节点, wi 是一个信号从源节点传递到目标节点的时间。现在,从某个节点
K 发出一个信号。需要多久才能使所有节点都收到信号?如果不能使所有节点收到信号,返回 -1 。Example
输入:times = [[2,1,1],[2,3,1],[3,4,1]], n = 4, k = 2
输出:2