Two Sigma Interview Question

leetcode medium question