Maintain real-time top-K products from events

Quick Overview

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.

Maintain real-time top-K products from events

Company: Amazon

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Onsite

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.

Quick Answer: 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.

|Home/Coding & Algorithms/Amazon
Amazon logo
Amazon
Sep 6, 2025, 12:00 AM
mediumSoftware EngineerOnsiteCoding & Algorithms
3
0

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.

Submit Your Answer to Earn 20XP

Sign in to leave a comment

Loading comments...