Enforce Rolling Daily and Monthly Send Limits per Customer
Last updated: November 29, 2026
Quick Overview
Build a checker that approves or rejects each new transfer so that a customer's total sent in any trailing 24-hour window and any trailing 30-day window stays under configured caps.
Remitly
November 29, 20260
0
0 solved
Build a checker that approves or rejects each new transfer so that a customer's total sent in any trailing 24-hour window and any trailing 30-day window stays under configured caps.
Remitly applies send limits that depend on a customer's verification tier and corridor, and they are evaluated as rolling windows rather than calendar days. The interviewer wants an efficient sliding-window structure that supports several windows at once and a clear rejection reason.
What the Interviewer Expects
- Models limits as trailing windows, not calendar buckets
- Keeps per-window running sums so each check is amortized O(1) per window
- Evicts expired entries correctly at window boundaries
- Rejects without mutating state when any limit would be exceeded
- Returns which limit was hit so the app can explain it
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 this work across many service instances with a shared store?
- A transfer is later cancelled and refunded. Should it count against the limit, and how do you remove it?
- How do limits change when a customer completes extra identity verification mid-window?
- How would you avoid a race where two concurrent sends both pass the check?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
Each call is try_send(customer, now, cents). Limits are a list of (window_seconds, cap_cents). A send is allowed if, for every window, the sum of accepted sends with timestamp in `(now - window, n...
High-Level Design
Keep one deque of accepted (ts, cents) per customer covering the largest window. For each window keep a start pointer into the deque and a running sum. On every call, advance each pointer past entri...