Adobe interview question

Algorithm about graph.