sir i have tried to do this by grouping them.
please tell the mistake.
Https://ide.codingblocks.com/s/207813 3 output are showing wrong
Please explain your approach.
Anyways, In this question you can find connect components. The cities in same connected components are reachable from each other but in different components are not.
sir in my approach i am
making an parent array and an order array
I am basically trying to assgin superparent to a group of connectec nodes
and by maintaining the oreder array I am storing the count of nodes that each superparent is holding
for example if a node has 3 children and any new node is connected to any of these nodes
then i will make superparent of these connected system as the superparent of the new node(basically grouping it) and increasing the order of the
and increasing the order of the superparent by 1
by this in the end I will have different superparent ,each with its no. of nodes it is having
in the end i am adding all the possible combination