Google interview question

Leetcode graph question that you solve with dps.