Hudson River Trading Interview Question

LC hard question multiple steps optimization