Google interview question

Graph problem, leetcode med - hard