Why is the answer of testcase 1 is 6 6 -1 ? Node 4 is reachable from node 1 via 2 so answer should be 12 ? (Since the graph is undirected)
Similarly for test 2 also.
Node 1 is reachable from 2 via 3, so why is ans -1 for that ?
Why is the answer of testcase 1 is 6 6 -1 ? Node 4 is reachable from node 1 via 2 so answer should be 12 ? (Since the graph is undirected)
Similarly for test 2 also.
Node 1 is reachable from 2 via 3, so why is ans -1 for that ?
HOW?
no links are given for the 4th node
1->2
|
3
4th is not connected to 1 in any way
so its value is -1 since 4th node is unreachable
similarly for the next example