How to Solve this Graph problem....
Anonymous User
382
Jun 10, 2020
Jun 11, 2020

This is a question asked in hack with infi round 2 ,can any one help how to solve it ?

image
image
for the given input
image

one of the possible path which gives us the answer is 1->3->4->7->3->5->2->1
the answer would be 6 because the distinct vertices are 6 (1,3,4,7,2,5).
as mentioned we can traverse an edge in the opposite direction up to one time, so we are using this opportunity to traverse from 5 to 2.

Comments (1)