Enforce a Rolling 24 Hour Marketing Text Cap Per Subscriber

Last updated: November 29, 2026

Quick Overview

Process a time-ordered stream of send attempts and decide which ones go out, so that no subscriber receives more than k marketing texts in any rolling 24 hour window, while transactional texts always send and do not count.

Attentive
Coding & Algorithms
Software Engineer
Attentive
November 29, 2026
Software Engineer
Technical Screen
Coding & Algorithms
Medium

0

0

0 solved


Process a time-ordered stream of send attempts and decide which ones go out, so that no subscriber receives more than k marketing texts in any rolling 24 hour window, while transactional texts always send and do not count.

Brands on Attentive run campaigns and triggered journeys (welcome, abandoned cart) at the same time, so one shopper can be targeted many times a day unless the platform caps frequency. The interviewer wants a sliding window per key, a precise eviction boundary, and a sense of how the logic would hold up in a distributed sender.

What the Interviewer Expects
  • Keep a per-subscriber deque of accepted marketing timestamps
  • Evict entries that fall out of the window before checking the cap
  • Count only accepted sends, not rejected attempts
  • Let transactional messages bypass the cap without being counted
  • State the window boundary (strict versus inclusive) and test it
  • Explain how this maps to a shared store across many workers
Key Topics to Cover
Sliding window
Deque
Rate limiting
Hash maps
Distributed counters
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
  • How would you implement this with Redis when hundreds of workers send concurrently?
  • Instead of dropping a capped message, how would you defer it to the earliest allowed time?
  • Should a journey message outrank a campaign message when both compete for the last slot?
  • How would you bound memory for tens of millions of subscribers?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice DSA Problems
Sample Answer
Requirements

Attempts come in timestamp order as (ts, subscriber, kind). A marketing attempt sends only if fewer than cap marketing sends were accepted for that subscriber in the last 24 hours, meaning timesta...

High-Level Design

Keep a map from subscriber to a deque of accepted marketing timestamps. For each attempt, pop old timestamps from the left, then compare the deque length with the cap. Because input is time-ordered, e...


Submit Your Answer
Markdown supported

Related Questions