Amazon Online Assessment Coding Interview: Top-K Popular Items Sold on Amazon

16 Views
No Comments

Amazon sells millions of products on its website, and for better customer experience, it wants to show a widget with the most popular items bought on the home page.

I’d like you to tell me how you’d go about calculating the top-k popular items sold on Amazon.

You can assume that you have a service, and your service gets notified in the form of a {customerId, itemId, timestamp} message whenever a customer purchases an item.

This problem is about counting item popularity from purchase events and maintaining the top-k items efficiently. A common approach is to aggregate counts in a hash map and then use a min-heap, bucket-based grouping, or periodic batch recomputation to keep the top-k results. If the system is streaming, you should also discuss incremental updates, concurrency, deduplication, and whether the ranking is over all time or a fixed time window.

END
 0