Google interview question

Leetcode Medium, graph traversals and dynamic programming