This is my code and i guess the logic is correct as i made a directed graph and applied dfs in it and count the minimum legth of the graph in it .
Vivek and Birthday Celebration getting segmentation fault in the code written by me
Algorithm ->
-> 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.
Refer this for better understanding -:
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.