In the pairing question hacker blocks discussed in this video

it is given that there are 2 connected components so let n1 be the number of nodes in 1st and n2 in 2nd so total ways to travwerse from one city to other n1*n2.but there can be a possibility of multiple connected components and we can traverse the city from one to two to three in this way also .than how weill calcaulate the number of ways in multiple connected compoents.

You don’t have to tell the number of paths between two cities, you have to tell the number ways end points of the path can be selected.
So one end point of the path lies in first connected component and second end point lies in some other connected component.

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.

1 Like