Schedule Outbound Follow-Up Texts With Quiet Hours and Caps

Last updated: November 29, 2026

Quick Overview

Given requested send times for follow-up SMS messages, each recipient's UTC offset, a local quiet window of 9pm to 8am, and a cap of 3 messages per recipient in any rolling 24 hours, compute the earliest legal send time for each message while keeping each recipient's messages in order.

EliseAI
Coding & Algorithms
Software Engineer
EliseAI
November 29, 2026
Software Engineer
Onsite
Coding & Algorithms
Medium

0

0

0 solved


Given requested send times for follow-up SMS messages, each recipient's UTC offset, a local quiet window of 9pm to 8am, and a cap of 3 messages per recipient in any rolling 24 hours, compute the earliest legal send time for each message while keeping each recipient's messages in order.

Automated lead and delinquency follow-ups must respect texting rules and not spam residents, so this models a real constraint the messaging pipeline enforces. Interviewers check that you handle two interacting constraints and that pushing for one does not break the other.

What the Interviewer Expects
  • Group by recipient and process in requested order
  • Convert to local time correctly for the quiet window
  • Use a sliding window (deque) for the rolling cap
  • Re-check quiet hours after a cap-induced delay, looping until both hold
  • Explain why the greedy earliest-time choice is optimal per recipient
Key Topics to Cover
sliding window
greedy scheduling
time zones
messaging compliance
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 do you make this a durable service rather than a batch function?
  • A recipient replies STOP: how do pending scheduled messages get cancelled?
  • How would daylight saving transitions break a fixed offset?
  • Different message types have different priorities under the same cap: what changes?
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

Times are UTC minutes. offsets[r] is local minus UTC. Allowed local window is [08:00, 21:00). At most cap sends in any window of 1440 minutes. Messages to one recipient keep order and never go out...

High-Level Design

Recipients are independent, so bucket by recipient and sort by request time. For each message start at max(request, previous send) and repeat two fixes until stable: move forward to the next allowed...


Submit Your Answer
Markdown supported

Related Questions