InterviewLegend

Heaps & Intervals

Alex Chen22 min readUpdated 81 real interview reports

A lot of what a trading firm computes is a running answer over a feed that never stops arriving. Think of the mid-price of a book as quotes update, or the median trade size over the last stretch of a session, or the earliest event across a set of market-data channels. Each is a question you answer again after every new tick, not once over a finished array. That is the shape this family tests. A heap gives you the current extreme of a moving set in constant time and re-ranks in log time. An interval sweep answers coverage over a line. Both show up wherever the prompt smells like an order book or a feed handler.

These are canonical problems, asked close to the way you already know them, so there is no disguised trick to unpick. The pressure is the one this loop applies everywhere. The online assessment runs on HackerRank against hidden tests, and a full pass is the expectation. The live rounds run in a shared editor that sometimes shows you a single visible case. You verify correctness yourself. The reject that stings most in this family is not a wrong algorithm. Candidate reports describe a median-from-a-stream answer whose only named miss was a missing base case for the empty stream. A clean heap you can write without fumbling, plus the base case surfaced before anyone asks, is what buys you the follow-up.

The Citadel angle
A running median of a price stream is the two-heap problem under a trading label, and the empty-feed base case is the edge Citadel grades. A live feed hands you values one at a time and asks for the running median after each. That is exactly the two-heap balance: a max-heap for the smaller half, a min-heap for the larger, rebalanced so their sizes never differ by more than one. Insertion is O(log n) and the read is O(1) off the two roots. The part that separates a pass from a reject is not the balance logic, it is defining what the function returns when nothing has arrived yet.
What's inside
  • 3 problems, worked step by step
  • about 22 min

Premium lessonCitadel interview guide

These took digging.

What candidates walked out with, from 20,000+ reports, forum threads behind logins and write-ups in Chinese. Then solved step by step.

100 companies. Checked every month.

Unlock all 100 companies

$49 a year · less than $1 a week · Cancel anytime

Had your Citadel interview?Tell us what they asked. Reviewed before it goes in, never with your name.
Citadel interview guide

Know what Citadel asks before you walk in.

12 coding · 5 system design · 15 behavioral questions

Get Premium$49 a year · Cancel anytime
Or start freeNo card.

Get their questions first.

InterviewLegend is independent and not affiliated with or endorsed by any company it covers.