Reported September 2026
Citadelheap priority queue

Top Ten Trades by Notional Value

Reported by candidates from Citadel's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.

Get StealthCoderRuns invisibly during the live Citadel OA. Under 2s to a working solution.
Founder's read

Citadel reported this one in September 2026, and it looks harder than it is. Strip the trading vocabulary and it's a top-K problem: multiply price by quantity, keep the ten biggest, break ties by input order. You've got an OA invite and not much time, so here's the shape of it. The side field is noise. If you blank on the heap mechanics under the clock, StealthCoder runs invisibly on your desktop as a safety net, but the logic below is short enough to carry in your head.

The problem

Given a finite batch of buy and sell trade records, return the IDs of the ten trades with the largest notional values. If there are fewer than ten trades, return every trade ID.
Each row of trades contains exactly four strings in this order:
tradeId: a unique identifier.
side: either BUY or SELL.
priceCents: a positive integer price in cents.
quantity: a positive integer quantity.
A trade's notional value is priceCents * quantity. Compute it with integer arithmetic. Rank trades by descending notional value. When two trades have the same notional value, the trade that appears earlier in the input ranks first.
Return the ranked tradeId values. Use a heap that retains at most ten candidates instead of sorting the complete input.

Function
topTenTrades(trades: String[][]) → String[]

Examples
Example 1
trades = [["t1","BUY","100","1"],["t2","SELL","50","10"],["t3","BUY","200","3"],["t4","SELL","90","2"],["t5","BUY","60","4"],["t6","SELL","75","5"],["t7","BUY","40","8"],["t8","SELL","110","2"],["t9","BUY","30","9"],["t10","SELL","20","20"],["t11","BUY","10","2"],["t12","SELL","300","2"]]
return = ["t3","t12","t2","t10","t6","t7","t9","t5","t8","t4"]
t3 and t12 both have notional value 600, so their input order breaks the tie. The two smallest trades, t11 and t1, do not enter the top ten.
Example 2
trades = [["a","BUY","1250","4"],["b","SELL","2500","2"],["c","BUY","999","3"]]
return = ["a","b","c"]
All three records are returned. Trades a and b both have notional value 5000, so a remains first because it appeared earlier.

Constraints
0 <= trades.length <= 200000.
Every row contains exactly four values in the documented order.
Every tradeId is unique and non-empty.
side is either BUY or SELL.
1 <= priceCents, quantity <= 10^9.
Numeric row fields are canonical base-10 integer strings without signs or separators.
The product priceCents * quantity fits in a signed 64-bit integer.
The intended selection complexity is O(n log 10) time with O(10) heap space, excluding the returned IDs.

Reported by candidates. Source: FastPrep

Pattern and pitfall

The trick is a min-heap capped at size ten. For each trade, compute notional as price times quantity, then push a tuple of notional and index. When the heap exceeds ten, pop the weakest. The weakest is the lowest notional, and on a tie the later index. That tie-break is where people lose points. Most languages give you a min-heap, so encode the key so the worst trade sits on top: compare notional ascending, then index descending. At the end, sort the surviving ten by notional descending, then index ascending, and map to IDs. Parse strings to 64-bit integers. In Java use long, in JavaScript use BigInt, since the product can pass 2^53. Don't sort all 200000 rows, the prompt asks for the heap. Empty input returns an empty list. If the heap logic slips live, StealthCoder is the hedge that hands you a working solution.

StealthCoder is the hedge for the one pattern you didn't drill. It runs invisibly during the screen share.

If this hits your live OA

You can drill Top Ten Trades by Notional Value cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. If you're reading this with an OA window open, you're who this was built for.

Get StealthCoder

Related leaked OAs

⏵ The honest play

You've seen the question. Make sure you actually pass Citadel's OA.

Citadel reuses patterns across OAs. If you're reading this with an OA window open, you're who this was built for. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Top Ten Trades by Notional Value FAQ

How hard is the Citadel Top Ten Trades question really?+

Easy to medium. It's a top-K selection with a tie-break rule. The difficulty is in the details: 64-bit math, string parsing, and getting the heap ordering right so ties favor the earlier trade. The algorithm itself is standard.

What's the trick to the tie-break?+

Store the input index with each notional value. Your heap's worst element is the lowest notional, and among equal notionals the highest index. Pop that one when size passes ten. The final output sorts by notional descending, then index ascending.

Do I need to worry about overflow?+

Yes. Price and quantity go up to 10^9, so the product can reach 10^18. That fits in a signed 64-bit integer but not in a 32-bit int. Use long in Java or C++, and BigInt in JavaScript. Python handles it natively.

Can I just sort the whole list instead of using a heap?+

It would produce the right answer, but the prompt explicitly asks for a heap retaining at most ten candidates. With 200000 rows, sorting is O(n log n) against O(n log 10). Use the heap to match what the problem asks for.

How do I prepare for this in 48 hours?+

Write a top-K with a bounded heap from scratch twice. Practice custom comparators with tie-breaks on index. Test the edge cases: zero trades, fewer than ten, all equal notionals, and maximum-size values. That covers essentially everything this problem tests.

Problem reported by candidates from a real Online Assessment. Sourced from a publicly-available candidate-aggregated repository. Not affiliated with Citadel.

OA at Citadel?
Invisible during screen share
Get it