Home
Log in
DescriptionSubmissionsSolution
DescriptionSubmissionsSolution
Loading...

Log in to run or submit

times =
n =
k =

Codey

Practise coding problems, test your solutions and track your progress.

Explore

  • Problems
  • About
  • Contact

Legal

  • Privacy Policy
  • Terms of Use

© 2026 Codey. Personal learning project.

Solution
Updated: 2026-02-23

Idea

Find the longest shortest-path time from k to all nodes.

Approach

Dijkstra’s algorithm on a directed weighted graph with non-negative weights. Compute shortest distances from k. Answer is max(dist) if all reachable, else -1.

Why it works

Dijkstra produces shortest paths with non-negative edges; the network delay is the slowest among them.

Code
Loading...
Complexity
Time: O((V+E) log V)
Space: O(V+E)
Solution
Updated: 2026-02-23

Idea

Find the longest shortest-path time from k to all nodes.

Approach

Dijkstra’s algorithm on a directed weighted graph with non-negative weights. Compute shortest distances from k. Answer is max(dist) if all reachable, else -1.

Why it works

Dijkstra produces shortest paths with non-negative edges; the network delay is the slowest among them.

Code
Loading...
Complexity
Time: O((V+E) log V)
Space: O(V+E)