Back to problems

Implement a News Publishing System with Topic Subscriptions and Delivery Limits

Object-Oriented Programming · Optiver · Medium

Approach 1 — Baseline: Replay the Stored News Log Before optimizing anything, it helps to have a version that is obviously correct. Keep every news item in one append-only log of (news_id, topic) pairs. Alongside it, keep a record per active subscriber: the interest set, the per-cycle cap, and a cursor — the index of the first log entry that might still be usable. The cursor is the whole trick of this baseline. Because an item is delivered in log order and a subscription's…

Checking your access…