Intuit interview question

Related to graphs and trees