Two Sigma interview question

Leetcode mid to hard problems.