IMC Trading interview question

2 leetcode medium problems, a little time crunch