Google interview question

Graph based algorithm.