Implement an Authorization Hold Manager With Expiry and Capture
Last updated: November 29, 2026
Quick Overview
Design a class for one credit card that places authorization holds against the available credit, captures them for a possibly different final amount, releases them, and expires holds that are never captured after a fixed time.
Capital One
November 29, 20260
0
0 solved
Design a class for one credit card that places authorization holds against the available credit, captures them for a possibly different final amount, releases them, and expires holds that are never captured after a fixed time.
Hotel, rental car and gas station charges place holds that later settle for a different amount, and stale holds that never settle must drop off so customers regain available credit. Capital One's Power Day coding rounds like object-design problems in this style, checking clean state handling, invariants on money, and edge cases around time.
What the Interviewer Expects
- Define available credit as limit minus posted balance minus active holds
- Reject duplicate authorization ids and non-positive amounts
- Expire holds lazily before every read or decision
- Allow capture for an amount different from the hold
- Explain the time boundary semantics for expiry
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
- The `available` call sums all holds. How would you make it O(1) or O(log n)?
- How would you make operations safe under concurrent authorizations for the same card?
- Should a capture above the hold amount ever be declined, and how much over is acceptable?
- How would you persist this so a service restart does not lose holds?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
- Amounts are integer cents;
nowis a timestamp. authorize(id, amount, now)succeeds only if the amount fits within available credit.capture(id, final, now)posts the final amount and remov...
High-Level Design
State: limit, posted balance and a dict of auth_id -> (amount, expires_at). Available credit is limit - posted - sum(active holds). Every public method first expires holds whose deadline is at or ...