Peak Total of Overlapping Card Authorization Holds

Last updated: November 29, 2026

Quick Overview

Each card authorization places a hold of some amount on a member's funds from a start time until it is released or captured. Given the holds as half-open intervals with amounts, return the largest total amount held at any instant and the earliest time it occurs.

SoFi
Coding & Algorithms
Software Engineer
SoFi
November 29, 2026
Software Engineer
Technical Screen
Coding & Algorithms
Medium

0

0

0 solved


Each card authorization places a hold of some amount on a member's funds from a start time until it is released or captured. Given the holds as half-open intervals with amounts, return the largest total amount held at any instant and the earliest time it occurs.

Galileo, SoFi's processing platform, tracks pending authorizations that reduce available balance until they settle or expire. The interviewer checks a sweep line over start and end events, correct tie handling at shared boundaries, and whether you can relate it to available balance calculations.

What the Interviewer Expects
  • Converts intervals into +amount and -amount events
  • Orders releases before new holds at the same timestamp for half-open intervals
  • Tracks a running sum and records the earliest time of the maximum
  • Ignores or rejects zero-length and inverted intervals explicitly
  • Explains O(n log n) and why a timeline array is worse for sparse timestamps
Key Topics to Cover
sweep line
intervals
event sorting
running sums
card authorizations
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
  • How would you answer 'held amount at time t' for many queries?
  • What changes if an authorization can be partially captured, reducing the hold?
  • How would you compute this per account across millions of accounts in a stream?
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

Holds are (start, end, amount_cents) active on [start, end). Return (peak, time) with the earliest time the peak is reached, (0, None) if there are no holds. A hold that ends exactly when anot...

High-Level Design

Turn each hold into two events: at start add the amount, at end subtract it. Sort by time, and at equal times put releases first (tag 0 before tag 1) so a release and a new hold at the same instan...


Submit Your Answer
Markdown supported