Cant figure out why code is giving runtime error
Hello @aryanv,
You have to create the adjacency list of size V+1.
Reason:
Node can have the value V also.
Modification:
adjList = new list[V+1];
Hope, this would help.
Hello @aryanv,
I have modified your code for the test case given in the question:
Now, your task is to correct it for the following cases:
-
Isolated node in the graph:
Example:
1
4 2 2 1
1 3
3 2
Expected Output:
6 (two temples and two road, 4 is iolated) -
When there are two different set of roads:
Example:
1
4 2 2 1
1 3
4 2
Expected Output:
6 (2 temples and 2 roads)
Hope, this would help.
Give a like if you are satisfied.
1 Like