A network consists of nodes labeled 0 to n. You are given a list of edges (a, b, t) describing the time t in seconds for a message to be sent from node a to node b. When a node receives a message, it immediately passes it on. Assuming all nodes are connected, determine how long it will take for every node to receive a message that begins at node 0. Input: first line n and m (nodes and edges), then m lines "a b t". Output: maximum time for all nodes to receive.
Example 1:
Example 2:
Constraints:
1 <= n <= 10^4 1 <= m <= 10^5 1 <= t <= 10^4 All edge weights non-negative
Tags:
