Two Sigma Interview Question

2 graph questions (DFS, connected components)