Atlassian Interview Question

A easy-medium problem involving DFS.