Uber phone screen

Anonymous User
1740
Oct 31, 2024
Nov 01, 2024

An online shopping website has a widget displaying the most popular items bought.
There is API service that sends a message contains (customer ID, item ID, timestamp) after each purchase transaction. Find the most popular items to be displayed on the widget.

I would like to hear your opinions, because I proposed two different solutions, and I didn't pass though.
Note: It's a live coding problem though, they wanted me to write a code to show the top K items.

Some ideas/hints worth to mention:

  • the top K items should updated every N minutes (let's say 10 mins), because it's a widget, and it should change with time.
  • The API service sends million of logs every minute, so the the required code should be flexible, and doesn't save everything in the memory first.

Thank you.

Comments (5)