Schedule Declined Charge Retries Under A Processor Rate Cap
Last updated: November 29, 2026
Quick Overview
Given declined charges with their decline hour, a list of retry delays, and a cap on retries the processor accepts per hour, produce the hour-by-hour retry schedule, pushing attempts to the next free hour when a slot is full.
Patreon
November 29, 20260
0
0 solved
Given declined charges with their decline hour, a list of retry delays, and a cap on retries the processor accepts per hour, produce the hour-by-hour retry schedule, pushing attempts to the next free hour when a slot is full.
Decline recovery is a major lever for creator revenue at Patreon, and retrying too aggressively hurts processor relationships and approval rates. The interviewer checks event-driven simulation with a heap, fairness ordering, and how capacity limits interact with dependent future events.
What the Interviewer Expects
- Uses a min-heap keyed by desired retry time so earlier demand gets earlier slots
- Schedules the next retry relative to when the previous attempt actually ran, not when it wanted to run
- Stops after the final retry or after success
- Tracks per-hour usage and slides to the next free hour
- Analyzes the cost of slot sliding and suggests a faster next-free-slot structure
Key Topics to Cover
How to Approach This
- Clarify input constraints and edge cases before writing code.
- Walk through your approach verbally and confirm with the interviewer before coding.
- Start with a brute force solution, then optimize. Mention time and space complexity.
- Test your solution with examples, including edge cases like empty input or duplicates.
- Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
- How would you prioritize retries by pledge amount or creator size when capacity is scarce?
- Slot sliding can be O(n) per attempt in a burst. How do you make it near O(1)?
- How would you vary delays by decline code (insufficient funds versus do-not-honor)?
- How does this run across many worker machines?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
Inputs: declines as (charge_id, decline_hour), delays like [24, 72] meaning retry 1 is 24h after the decline and retry 2 is 72h after retry 1 fails, per_hour_cap, and for testing a map of wh...
High-Level Design
This is a discrete event simulation. Push each charge's first desired retry onto a min-heap (desired_hour, charge_id, attempt). Pop the earliest, find the first hour at or after desired_hour with ...