Robinhood Interview Question

algorithm on white board