Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Day 270 #548

Closed
vaskoz opened this issue May 19, 2019 · 0 comments · Fixed by #550
Closed

Day 270 #548

vaskoz opened this issue May 19, 2019 · 0 comments · Fixed by #550
Assignees

Comments

@vaskoz
Copy link
Owner

vaskoz commented May 19, 2019

Good morning! Here's your coding interview problem for today.

This problem was asked by Twitter.

A network consists of nodes labeled 0 to N. You are given a list of edges (a, b, t), describing the time t it takes for a message to be sent from node a to node b. Whenever a node receives a message, it immediately passes the message on to a neighboring node, if possible.

Assuming all nodes are connected, determine how long it will take for every node to receive a message that begins at node 0.

For example, given N = 5, and the following edges:

edges = [
    (0, 1, 5),
    (0, 2, 3),
    (0, 5, 4),
    (1, 3, 8),
    (2, 3, 1),
    (3, 5, 10),
    (3, 4, 5)
]

You should return 9, because propagating the message from 0 -> 2 -> 3 -> 4 will take that much time.

@vaskoz vaskoz self-assigned this May 19, 2019
@vaskoz vaskoz mentioned this issue May 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant