Amazon | SDE2 | Coding Round | Graphs
Anonymous User
546

Question :

Given a network of N routers, numbered 1 to N.  
We need to find the max amount of speed of data transfer that can happen from 1 to N.
Two routers can be connected via a directed edge.
Let M be total number of edges in this network.
Each directed edge has a weight representing number of MBPS of data that can pass through that edge.
We need to find the max amount of data that can pass per second from router 1 to router N in this network.

Example :
image

Consider above example.

Max data can be transferred would be,
Edge --- Speed
1-> 2 ---- 2
1-> 3 ---- 3
2 -> 4 ---- 1
4 -> 5 --- 6

for this, max data can be transferred is, 3.
Because,
maximum data transfer to router 4 would be 3 only.
Paths from 1, 4 are
1->2->4 -- only 1MBPS can be reached to 4 (because, 2->4 has limit of 1MBPS)
1->3->4 -- only 2MBPS can be reached to 4 (because, 3->4 has limit of 2MBPS)
so data transfer from 1->4 would be 3.

And even though 4->5 has 6MBPS capacity, only 3MBPS can be reached to router 5 (because router 4 is getting only 3MBPS as input)

Comments (6)