Two Sigma interview question

lc medium question, no design questions