Two Sigma Interview Question

No behavioural just code and walk-through of logic