Time Windows, Scheduling, And Notifications
Asked of: Software Engineer
Last updated
What's being tested
These problems test interval algorithms, event-driven simulation, and stateful time processing over ordered data. You must normalize time zones and boundary semantics, merge or subtract windows efficiently, process same-timestamp events deterministically, and preserve correctness across recurring schedules and account state changes.
Patterns & templates
-
Sweep line for interval union/difference: sort endpoints, track active counts, and emit transitions in
O(n log n)time. -
Convert recurring weekly times to integer minutes in
[0, 10080), apply offsets modulo a week, and explicitly handle wraparound intervals. -
For allowed-minus-freeze windows, merge overlaps first, subtract freezes with two pointers, then filter by lead time, minimum duration, and result cap.
-
Use a priority queue or k-way merge for notification streams; define deterministic ordering by timestamp, event type, and stable identifier.
-
Model account changes as ordered events with explicit state transitions; renewal, cancellation, and plan-change precedence must be documented.
-
Use a rolling window with a deque or per-key queues; evict timestamps
< current - window, maintainingO(n)total work. -
Separate computation from rendering: calculate eligible notifications first, sort/filter efficiently, then apply templates; avoid repeated scans over large account lists.
Common pitfalls
Pitfall: Treating interval endpoints inconsistently; choose half-open
[start, end)semantics so adjacent windows do not create false overlap.
Pitfall: Applying time-zone offsets after filtering; convert candidate intervals to UTC before lead-time comparisons, while preserving duration.
Pitfall: Assuming input order resolves ties; explicitly specify same-time event precedence and stable tie-breakers.
Practice these
The practice cards below cover the canonical variants — solve all of them and time yourself.
Practice questions
- Find deployable slots in a recurring week from allowed and freeze windowsStripe · Software Engineer · Onsite · medium
- Deployment Window Scheduler: Allowed Minus Freeze Windows, Time Zones, FiltersStripe · Software Engineer · Online Assessment · hard
- Subtract Blocked Periods from Allowed Deployment WindowsStripe · Software Engineer · Online Assessment · hard
- Generate Account Email NotificationsStripe · Software Engineer · Technical Screen · medium
- Detect Trigger and Resolve EventsStripe · Software Engineer · Technical Screen · hard
- Schedule Welcome and Expiration Emails from Subscription RecordsStripe · Software Engineer · Technical Screen · medium
- Implement account scheduler with locking and LRUStripe · Software Engineer · Technical Screen · medium
- Generate user notifications from schedulesStripe · Software Engineer · Technical Screen · medium
- Design a subscription email scheduler with changes and renewalsStripe · Software Engineer · Technical Screen · medium
Related concepts
- Intervals, Sliding Windows, And Time-Ordered StateCoding & Algorithms
- Interval Scheduling And Calendar SystemsCoding & Algorithms
- Sliding Window And Time Window Counters
- Intervals, Line Sweep, and Difference ArraysCoding & Algorithms
- Sliding Window Counters and Rate LimitingSystem Design
- Intervals, Line Sweep, And Range UpdatesCoding & Algorithms