Emit Best Bid and Offer Changes From Level-Two Updates

Last updated: November 29, 2026

Quick Overview

Given a stream of price-level updates (sequence number, side, price, new aggregate size, where size zero deletes the level), output the top of book every time the best bid or offer price or size changes.

Virtu Financial
Coding & Algorithms
Software Engineer
Virtu Financial
November 29, 2026
Software Engineer
Technical Screen
Coding & Algorithms
Medium

0

0

0 solved


Given a stream of price-level updates (sequence number, side, price, new aggregate size, where size zero deletes the level), output the top of book every time the best bid or offer price or size changes.

Virtu consumes depth-of-book feeds from hundreds of venues and most strategies only react to top-of-book changes, so suppressing no-op updates matters for latency. The screen checks efficient best-level tracking under deletions and correct change detection.

What the Interviewer Expects
  • Maintain per-side level sizes in a hash map
  • Track the best price with a heap and discard stale entries lazily
  • Compare the full (price, size) tuple to decide whether to emit
  • Handle a side becoming empty
  • State the cost per update
Key Topics to Cover
order book
heap
change detection
market data
lazy deletion
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
  • How would this change if you needed the top five levels instead of one?
  • What if the feed sends order-level (add, modify, delete) messages instead of aggregated levels?
  • How would you build a consolidated BBO across several venues?
  • How would you detect a crossed or locked book and what would you do with it?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice DSA Problems
Sample Answer
Requirements

Updates are (seq, side, price, size). Size 0 removes the level; otherwise it replaces the aggregate size. After each update, if (bid_px, bid_sz, ask_px, ask_sz) differs from the last emitted value...

High-Level Design

For each side keep size[price] and a heap of prices (negated for bids). A level can be deleted without touching the heap; when we look at the top we pop prices whose size is gone. A price is pushed ...


Submit Your Answer
Markdown supported

Related Questions