Merge Rider Accounts That Share a Phone Number or Card

Last updated: November 29, 2026

Quick Overview

Each rider account lists identifiers such as phone numbers and payment card fingerprints; two accounts belong to the same person if they share any identifier, directly or through a chain. Return groups of account ids that should be merged.

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

0

0

0 solved


Each rider account lists identifiers such as phone numbers and payment card fingerprints; two accounts belong to the same person if they share any identifier, directly or through a chain. Return groups of account ids that should be merged.

Uber's risk and identity teams link accounts to catch promo abuse and banned riders returning under new emails. The onsite checks whether you model this as connected components and use union find keyed by identifier, rather than comparing every pair of accounts.

What the Interviewer Expects
  • Model accounts as nodes connected through shared identifiers
  • Map each identifier to the first account that used it
  • Use union find with path compression and union by size
  • Group accounts by root and return deterministic output
  • Discuss false merges from shared family cards
Key Topics to Cover
union find
connected components
hash map
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 avoid merging accounts linked only by a shared corporate card used by thousands?
  • How would you run this incrementally as new accounts sign up?
  • How would you scale this to billions of identifiers in a batch job?
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: accounts, list where accounts[i] is a list of identifier strings.
  • Output: list of groups of account indices, each sorted, groups sorted by first element.
  • Transitive: A shares with B, ...
High-Level Design

Pairwise comparison is O(n^2 x L). Instead, walk every identifier and keep owner[id], the first account seen with it. When an identifier is seen again, union the current account with its owner. Afte...


Submit Your Answer
Markdown supported