InterviewDB Question

Orderbook - Implement a Limit Order Book with Matching Engine

Question Details

Problem Implement a limit order book for a single trading pair. Support: place_order(order_id, side, price, quantity) - add a limit order ("buy" or "sell"). cancel_order(order_id) - remove the order. get_best_bid() -> float - highest buy price with resting quantity. get_best_ask() -> float - lowest sell price with resting quantity. Automatically match orders when best bid >= best ask. Example: Follow-ups What data structures give O(log n) insert/delete and O(1) best-bid/ask lookup? How do you ha…

Full Details

🔒

Unlock all Two Sigma questions

Full insider details, leaked discussions, and candidate experiences.

Get full access — $100 a year, unlimited access

About This Question

This is a reported interview question from a two sigma interview during the phone round.

It covers the following topics: Coding, Queue, Phone, Onsite .