← 返回 atlassian 的题目列表Popular Content Counter
类型:qbank
Design a content-popularity tracker with increment, decrement, and most-popular operations. Follow-ups push toward O(1) operations and deterministic tie-breaking when multiple content IDs share the top score.
Requirements
Implement:
increasePopularity(contentId)
decreasePopularity(contentId)
getMostPopular() / mostPopular()
increasePopularity increments the content score.
decreasePopularity decrements the content score.
getMostPopular returns a content ID with the highest current popularity.
Follow-ups include optimizing the operations to O(1) and deciding what to return when multiple content IDs tie.
One tie-break variant asks for the earliest content ID that reached the top score through increasePopularity.
Notes
Candidates explicitly connect the optimized follow-up to the LC 432-style all-O(1) data structure.
Clarify whether scores can become negative, whether zero-score content should remain tracked, and what to return when the structure is empty.
Preparation
Implement the simple hash-map plus scan version first.
Then implement the bucketed doubly linked list version with content IDs grouped by count.