Back to problems

Design a Top-Ten Trade Query with Exact Amounts

Algorithm · Citadel · Medium

You are building a library that ingests a chronological list of trade records and must efficiently answer queries for the top 10 buy trades and top 10 sell trades at any point in the data stream. Each trade record includes a side (BUY or SELL), a symbol (e.g., AAPL), an integer quantity, a decimal price with two fractional digits, and a Unix timestamp in milliseconds. Before you begin coding, you must define a ranking contract – a deterministic way to compare trades and…

Checking your access…