Track Top K Absolute Movers Under Live Price Updates
Last updated: November 29, 2026
Quick Overview
Implement a structure with update(symbol, price) and top_k(k). Each symbol's first price is its reference; top_k returns the k symbols with the largest absolute percentage move from reference, largest first.
Point72
November 29, 20260
0
0 solved
Implement a structure with update(symbol, price) and top_k(k). Each symbol's first price is its reference; top_k returns the k symbols with the largest absolute percentage move from reference, largest first.
Trading desks at Point72 watch movers screens all day, and the infrastructure behind them has to absorb many updates between queries. The interviewer is testing heap usage with lazy deletion and a reasoned trade-off between update cost and query cost.
What the Interviewer Expects
- Store each symbol's reference and latest move in a dictionary
- Push (negative move, version, symbol) onto a heap on every update
- Discard stale heap entries at query time by checking versions
- Restore the popped valid entries after answering a query
- Compare with a simple nlargest scan and explain when each wins
- Bound heap growth with periodic rebuilds
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
- Updates outnumber queries a thousand to one: which design would you pick?
- How would you support a time window, such as move over the last five minutes?
- How do you keep the heap from growing without bound?
- How would you shard this across machines for 50,000 symbols?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
The reference price is the first price seen for a symbol (in practice, the prior close). A move is the absolute percentage change from that reference. Updates are frequent; queries are occasional but ...
High-Level Design
Keep dictionaries for reference, current move and a per-symbol version counter. Every update pushes a new heap entry keyed by negative move. Old entries for that symbol remain in the heap but carry st...