Squarepoint Capital interview question

Leetcode question, a practical guild to quantitative finance interviews