Cluster Customer Records Sharing Emails, Phones or Devices

Last updated: November 29, 2026

Quick Overview

Given customer records that each carry an optional email, phone number and device fingerprint, treat two records as the same person when they share any normalized attribute. Return the number of distinct customers and the record ids in the largest cluster.

Capital One
Coding & Algorithms
Software Engineer
Capital One
November 29, 2026
Software Engineer
Onsite
Coding & Algorithms
Medium

0

0

0 solved


Given customer records that each carry an optional email, phone number and device fingerprint, treat two records as the same person when they share any normalized attribute. Return the number of distinct customers and the record ids in the largest cluster.

Identity resolution sits under Capital One's fraud, onboarding and marketing systems, for example spotting one person behind several credit applications. In a Power Day coding round this tests whether you recognize transitive grouping as a union-find problem and avoid comparing every pair of records.

What the Interviewer Expects
  • Map each normalized attribute value to the first record that used it
  • Union records that share a value instead of comparing all pairs
  • Implement find with path compression and union by size
  • Namespace keys by attribute so an email never collides with a phone
  • Return a deterministic largest cluster on ties
Key Topics to Cover
Union find
Path compression
Entity resolution
Hash maps
Normalization
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
  • A shared device in a public library links thousands of strangers. How would you stop very common values from merging clusters?
  • How would you support adding records one at a time while keeping counts current?
  • How would you split a cluster if a record is later deleted?
  • How would you run this on a billion records with a distributed framework?
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 and optional email, phone and device values.
  • Sharing any one normalized value (trimmed, lowercased) links two records, and links are transitive.
  • Return `(cluster_co...
High-Level Design

Comparing every pair is O(n^2). Instead, keep owner[(attr, value)] -> first record index. When a later record has the same key, union it with the owner. Every record touches at most three keys, so t...


Submit Your Answer
Markdown supported