Design a library that parses trade data and returns the top ten buys and sells. Explain the ranking contract, exact amount handling, object responsibilities, and a heap-based selection approach.
### Constraints & Assumptions
The report does not state whether “top ten” means individual records, entities, quantities, or aggregated amounts, nor the time window or tie rule. Preserve those as required contract decisions. Do not invent a particular ranking metric or claim a unique output from the source alone.
### Clarifying Questions
What is ranked and by which score? Are buys and sells separate lists? Is aggregation required? How are equal scores ordered? What data size, time tolerance/window, partial-fill, and streaming requirements apply?
### What a Strong Answer Covers
Typed parsing, a separate scoring/aggregation policy, exact arithmetic, bounded top-k selection, deterministic ties once specified, and honest state costs for streaming updates.
### Follow-up Questions
Why is a size-ten heap sufficient only after candidate scores are well defined? What changes if an entity's score can later increase or decrease? How can timestamp imprecision affect membership in a reporting window?
Overview: Design a top-ten trade query around an explicit ranking contract, exact monetary aggregation, bounded heaps, timestamp boundaries, and mutable-score streaming tradeoffs.
Design a library that parses trade data and returns the top ten buys and sells. Explain the ranking contract, exact amount handling, object responsibilities, and a heap-based selection approach.
Constraints & Assumptions
The report does not state whether “top ten” means individual records, entities, quantities, or aggregated amounts, nor the time window or tie rule. Preserve those as required contract decisions. Do not invent a particular ranking metric or claim a unique output from the source alone.
Clarifying Questions Guidance
What is ranked and by which score? Are buys and sells separate lists? Is aggregation required? How are equal scores ordered? What data size, time tolerance/window, partial-fill, and streaming requirements apply?
What a Strong Answer Covers Guidance
Typed parsing, a separate scoring/aggregation policy, exact arithmetic, bounded top-k selection, deterministic ties once specified, and honest state costs for streaming updates.
Follow-up Questions Guidance
Why is a size-ten heap sufficient only after candidate scores are well defined? What changes if an entity's score can later increase or decrease? How can timestamp imprecision affect membership in a reporting window?