Two Sigma interview question

2 graph questions (DFS, connected components)