PracHub
QuestionsPremiumLearningGuidesCheatsheetNEWCareers
|Home/Coding & Algorithms/Amazon

Maintain real-time top-K products from events

Last updated: Mar 29, 2026

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.

  • Medium
  • Amazon
  • Coding & Algorithms
  • Software Engineer

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.

Related Interview Questions

  • Find Valid IP Addresses in Files - Amazon (medium)
  • Implement Optimal Bucket Batching - Amazon (hard)
  • Implement Cache and Rotate Matrix - Amazon (medium)
  • Find Longest Activatable Server Streak - Amazon (hard)
  • Build the Largest Available Sequence - Amazon (medium)
Amazon logo
Amazon
Sep 6, 2025, 12:00 AM
Software Engineer
Onsite
Coding & Algorithms
0
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.

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Amazon•More Software Engineer•Amazon Software Engineer•Amazon Coding & Algorithms•Software Engineer Coding & Algorithms
PracHub

Master your tech interviews with 7,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • Careers
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.