IMC Trading interview question

One Leetcode question with some changes, the other one is unseen before.