Optiver interview question

I have been sent a Hackerrank exercise