
Sponsored
Sponsored
Use these hints if you're stuck. Try solving on your own first.
Store the backlog buy and sell orders in two heaps, the buy orders in a max heap by price and the sell orders in a min heap by price.
Store the orders in batches and update the fields according to new incoming orders. Each batch should only take 1 "slot" in the heap.