Two Sigma Interview Question

basic dfs