IMC Trading Interview Question

2 leetcode medium problems, a little time crunch