Two Sigma Interview Question

Medium difficulty algorithm + OOP design and implementation of it