Uber phone screen
Company: Uber
Role: software engineer ii
Interview Stage: Phone Screen
Original Post Content:
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 be updated every N minutes (let's say 10 mins), because it's a widget, and it should change with time.
* The API service sends millions of logs every minute, so the required code should be flexible, and doesn't save everything in the memory first.
Thank you.