Design a Content Popularity Tracker
Medium · Low-Level Design · about 35 minutes
Asked at Atlassian, Reddit, LinkedIn, Zillow, Discord, Yelp, Quora.
Design a class that tracks the popularity of content items (pages, posts). increase(id) and decrease(id) change an item's score by one, and most_popular() returns an item with the highest positive score, or nothing if there is none. Every operation should be O(1).