Arbitrate Redundant A and B Feed Lines Into One Stream
Last updated: November 29, 2026
Quick Overview
Exchanges publish identical packets on two or more redundant lines, each in sequence order but with different delays and drops. Merge the lines into a single stream that emits every sequence number exactly once, in order, taking whichever copy arrives first.
DRW
November 29, 20260
0
0 solved
Exchanges publish identical packets on two or more redundant lines, each in sequence order but with different delays and drops. Merge the lines into a single stream that emits every sequence number exactly once, in order, taking whichever copy arrives first.
Line arbitration is a staple of low latency market data at firms like DRW, and it is a natural way to test k-way merging with a heap. The interviewer checks ordering, duplicate suppression, and whether you can talk about what changes when lines are live rather than finished lists.
What the Interviewer Expects
- Uses a min-heap keyed on sequence number with a tie breaker
- Emits each sequence once by comparing to the last emitted value
- Handles empty lines and uneven lengths
- Writes a generator so output streams instead of materializing
- Explains O(N log k) time and O(k) heap space
Key Topics to Cover
How to Approach This
- Clarify input constraints and edge cases before writing code.
- Walk through your approach verbally and confirm with the interviewer before coding.
- Start with a brute force solution, then optimize. Mention time and space complexity.
- Test your solution with examples, including edge cases like empty input or duplicates.
- Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
- The lines are live sockets: how do you avoid waiting forever on a line that dropped a packet?
- With exactly two lines, what simpler structure beats a heap?
- How do you detect that one line is consistently slower and alert on it?
- What if payloads for the same sequence differ between lines?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
Each line is an iterable of (seq, payload) in strictly increasing seq. Lines overlap heavily. Output: (seq, payload) for every distinct seq across all lines, ascending, using the first copy popped...
High-Level Design
Classic k-way merge. Seed a heap with the first element of each line, tagged with the line index so ties never compare payloads. Pop the smallest, emit it unless it equals the last emitted sequence, t...