Match Uploaded Receipts to Card Transactions Within a Date Window

Last updated: November 29, 2026

Quick Overview

Given card transactions and uploaded receipts, each with an amount in cents and a day, pair as many receipts as possible with transactions of the exact same amount whose days differ by at most a window. Each item can be used once.

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

0

0

0 solved


Given card transactions and uploaded receipts, each with an amount in cents and a day, pair as many receipts as possible with transactions of the exact same amount whose days differ by at most a window. Each item can be used once.

Ramp auto-matches receipts from email and SMS to card swipes so employees do not have to, and the matching must maximize coverage, not just grab the nearest candidate. The interviewer wants grouping by amount, a sorted two-pointer sweep, and an argument for why the greedy is optimal.

What the Interviewer Expects
  • Groups by amount with a hash map so only same-amount items are compared
  • Sorts by day and uses two pointers for O(n log n) overall
  • Explains why nearest-first greedy can strand a receipt and why the sweep does not
  • Handles amounts that appear on only one side
  • Returns pairs, not just a count
Key Topics to Cover
Hashing
Two pointers
Sorting
Greedy matching
Exchange argument
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
  • Amounts can differ by a tip of up to 20%. How does the matching change?
  • How would you prefer closer matches among all maximum matchings?
  • What if a receipt can match the sum of two split transactions?
  • How would this run incrementally as new receipts arrive?
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

Input: transactions and receipts as (id, amount_cents, day). A receipt matches a transaction if amounts are equal and |day_r - day_t| <= window. Output the largest possible set of disjoint pai...

High-Level Design

Amounts must match exactly, so bucket both lists by amount and solve each bucket independently. Within a bucket every receipt covers the interval [day - w, day + w], all the same width, and transact...


Submit Your Answer
Markdown supported