This question evaluates streaming data aggregation, weighted heavy‑hitter ranking, and the design of efficient data structures and algorithms for real-time top‑K tracking in the Coding & Algorithms domain.
Design a data structure/class that ingests a stream of product events and returns the current top‑K products at any time. Events include {timestamp, product_id, event_type} where event_type may be view, add_to_cart, or purchase with configurable weights. Support: update(event), query_top_k(k), and optionally query within a sliding time window W. Specify tie‑breaking, required update and query complexities, and the data structures (e.g., heaps + hash maps, count‑min sketch for heavy hitters). Discuss memory bounds, backfill/replay handling, and concurrency if multiple threads update.