Uber interview question

Leetcode hard problem related to graphs and DFS.