Two Sigma Interview Question

One simple algorithmic question