Intuit Interview Question

Related to graphs and trees