Citadel Securities interview question

Two leetcode questions: medium, hard