This question evaluates a candidate's ability to design and maintain dynamic aggregate metrics from nested or incremental inputs, emphasizing data modeling, streaming updates, and the use of appropriate data structures and algorithms to compute least-k aggregates.
Now assume revenue is not provided as a flat list of events, but may be nested, for example:
(customer_id, delta_amount)
events.
You need to support the query:
“Return the
kcustomers with the smallest total revenue.”
delta_amount
updates)?
leastK()
queries, fewer updates)
Assume you do not need to write full code, but must clearly describe data structures, operations, and complexity.