why is it not 12 6.
given o/p is -1 6
Help me to understand the given second test case
There are 3 nodes in the graph, but only one edge from 2 to 3.
Therefore distance between 2 and 3 is 6.
Now 1 is disconnected from both 2 and 3 ,hence its distance from 2 is -1.
I see that ans for second case should be -1 6 only.
Where do you face the problem in understanding this.
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.