Match Clearing Records to Authorizations With Tip Tolerance

Last updated: November 29, 2026

Quick Overview

Given authorizations and clearing records, each with a card, merchant, day and amount in cents, pair each clearing record with at most one authorization of the same card and merchant so that the clearing posts within a set number of days after the authorization and its amount is within an allowed percentage band of the authorized amount. Return a pairing with the maximum number of matches.

American Express
Coding & Algorithms
Software Engineer
American Express
November 29, 2026
Software Engineer
Onsite
Coding & Algorithms
Hard

0

0

0 solved


Given authorizations and clearing records, each with a card, merchant, day and amount in cents, pair each clearing record with at most one authorization of the same card and merchant so that the clearing posts within a set number of days after the authorization and its amount is within an allowed percentage band of the authorized amount. Return a pairing with the maximum number of matches.

As issuer and acquirer in a closed loop, American Express must release authorization holds when the final clearing arrives, and restaurants and hotels routinely clear for a different amount than they authorized. The interviewer is looking for the insight that greedy closest-amount matching fails and that this is bipartite matching within each card and merchant group.

What the Interviewer Expects
  • Groups by card and merchant to shrink the problem
  • Shows a counterexample where greedy matching strands a record
  • Models it as maximum bipartite matching and implements augmenting paths
  • Uses integer math in cents and basis points
  • Discusses what to do with unmatched holds and clearings
Key Topics to Cover
Bipartite matching
Augmenting paths
Greedy counterexamples
Reconciliation
Integer arithmetic
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 prefer the pairing with the smallest total amount difference among maximum matchings?
  • What if one authorization can be cleared in several partial shipments?
  • How would you run this incrementally as clearing files arrive each day?
  • When should an unmatched hold be released automatically?
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

Inputs: auths as (auth_id, card, merchant, day, cents) and clearings in the same shape. A clearing c may match auth a if both share card and merchant, a.day <= c.day <= a.day + max_days, a...

High-Level Design

Greedy fails. Auths 50.00 and 58.00, clearings 59.00 and 69.00 with a 20% tip band. Closest-amount greedy sends 59.00 to 58.00, and then 69.00 has nothing (50.00 * 1.2 = 60.00). The optimal pairing is...


Submit Your Answer
Markdown supported

Related Questions