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
Coding & Algorithms
Software Engineer
Capital One
November 29, 2026
Software Engineer
Onsite
Coding & Algorithms
Medium

0

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
Object-oriented design
State management
Expiry with TTL
Money invariants
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
  • 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 Problems
Sample Answer
Requirements
  • Amounts are integer cents; now is 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 ...


Submit Your Answer
Markdown supported