Vivek and Birthday Celebration

Can someone provide editorial for Vivek and Birthday Celebration problem. I have submitted it but looking for better approach.

My code :

Hint -:
For each pair p(a,b), we add a connection from a to b i.e. we insert ‘b’ to the node[a]. Thus if ‘a’ is selected ‘b’ would automatically be selected.
Now we take each node[i] and traverse through the connections till all the leaf nodes and count the total nodes directly/indirectly connected to that particular node[i].
We find that node[i] which has the minimum number of connections.

1 Like