Merge Duplicate Vendor Records Sharing a Tax ID or Email

Last updated: November 29, 2026

Quick Overview

Vendor records imported from bills, cards and the ERP contain duplicates. Two records are the same vendor if they share a tax id or any billing email, directly or through a chain. Return the merged groups of record ids.

Ramp
Coding & Algorithms
Software Engineer
Ramp
November 29, 2026
Software Engineer
Onsite
Coding & Algorithms
Medium

0

0

0 solved


Vendor records imported from bills, cards and the ERP contain duplicates. Two records are the same vendor if they share a tax id or any billing email, directly or through a chain. Return the merged groups of record ids.

Ramp's bill pay and procurement products build a vendor list from many sources, and duplicate vendors cause duplicate payments and broken spend reporting. The interviewer wants union-find over shared keys, normalization of the keys, and attention to transitive merges.

What the Interviewer Expects
  • Recognizes transitive equivalence and reaches for union-find or graph components
  • Maps each normalized key to the first record that owned it to avoid O(n^2) comparisons
  • Normalizes emails (case, whitespace) and tax ids (dashes)
  • Implements path compression and union by rank
  • Produces deterministic, sorted output
Key Topics to Cover
Union-find
Hashing
Connected components
Data normalization
Entity resolution
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 pick the surviving 'golden' record and merge its fields?
  • Shared generic emails like [email protected] would merge unrelated vendors. How do you guard against that?
  • How would you support un-merging a wrong merge?
  • How would this run incrementally as new vendors 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

Each record has an id, an optional tax_id, and a list of emails. Records sharing any normalized key are the same vendor, transitively. Output groups of ids, each sorted, groups ordered by their ...

High-Level Design

Comparing every pair is O(n^2) and still misses chains unless repeated. Instead, treat each key as a hub: the first record that uses a key owns it, and any later record with the same key is unioned wi...


Submit Your Answer
Markdown supported