Problem Link
Considering the below graph, we get
6
  
  
If we start traversing the graph from node 1, then we will traverse like 1->5->3->2->4->6->1 (as a ring).
For 3<-2 we will take its weight negative for 3->2.
Now we will add the negative weights and positive weights respectively then print the minimum between them.
Solution:
Considering the below graph, we get
6
 1
  5 4
 5
  3 8
 2
  4 15
 1
  6 16
 2
  3 23
 4
  6 42
If we start traversing the graph from node 1, then we will traverse like 1->5->3->2->4->6->1 (as a ring).
For 3<-2 we will take its weight negative for 3->2.
Now we will add the negative weights and positive weights respectively then print the minimum between them.
Solution:


No comments:
Post a Comment