Domanda di colloquio di Two Sigma

some bfs dfs question with math and binary search