Two Sigma interview question

basic dfs