The finance terminology threw me off at first.
Clarify requirements and edge cases, then design a data structure that efficiently maintains per-exchange order books and a global view. Implement the QuoteBook class with methods for per-exchange and national best bid/offer, ensuring correct aggregation of quantities at the best price levels.
Pro tip: Discuss the trade-offs between different data structures (e.g., heaps vs. sorted maps) and how they affect performance for high-frequency updates, showing awareness of real-world trading systems.
Ask about input format, update frequency, and whether orders can be modified or cancelled. Confirm that 'best bid' means highest price and 'best ask' means lowest price, and that quantities at the same price are summed.
Propose maintaining a separate order book per exchange, each with a data structure for bids and asks (e.g., sorted maps or heaps). Also maintain a global order book aggregating all exchanges for national best bid/offer.
For a given exchange, retrieve the best bid and ask from its order book. If multiple orders at the best price, sum their quantities. Return None if no orders on that side.
Aggregate orders across all exchanges to find the highest bid and lowest ask nationally. Sum quantities at the best price levels. Return None if no orders exist on a side.
Discuss time and space complexity of operations, and trade-offs between different data structures (e.g., heaps for O(1) best price vs. sorted maps for ordered traversal). Mention potential optimizations for high-frequency updates.
AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.