Squarepoint Capital interview question

Leetcode easy to medium question