Google interview question

Graph traversal and a DP question