Hudson River Trading interview question

LC hard question multiple steps optimization