Two Sigma Interview Question

lc medium question, no design questions