Object-Oriented Programming · Citadel · Medium
Min-Heap Merge (k‑way merge) Each stream is sorted by timestamp, so we have a classic merge‑k‑sorted‑lists structure. The twist is that multiple events can share the same timestamp; their price changes must be combined before we record the new current price. A min‑heap lets us always pick the next earliest timestamp across all streams in O(log K) time. When we extract an event, we also drain all other events in the heap that carry the same timestamp, summing their deltas.…
Checking your access…