Two Sigma interview question

Leetcode 1 easy, 2 mediums