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
Coding & Algorithms
Software Engineer
Point72
November 29, 2026
Software Engineer
Onsite
Coding & Algorithms
Medium

0

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
heaps
lazy deletion
top-k
versioning
streaming
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. 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 Problems
Sample 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...


Submit Your Answer
Markdown supported