Merge Duplicate User Identities Across Connected Directories

Last updated: November 29, 2026

Quick Overview

You are given user records imported from several sources (Active Directory, Workday, Google Workspace), each with an id and a map of attributes such as email, employee_id and phone. Group the records that belong to the same person, where two records match if they share any attribute name with the same normalized value, including transitively.

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

0

0

0 solved


You are given user records imported from several sources (Active Directory, Workday, Google Workspace), each with an id and a map of attributes such as email, employee_id and phone. Group the records that belong to the same person, where two records match if they share any attribute name with the same normalized value, including transitively.

Okta Universal Directory links profiles from many sources into one identity, and import matching rules decide when two accounts are the same person. Onsite coding rounds like this test whether you see the transitive linking as connected components and implement union find cleanly, plus how you handle dirty attribute data.

What the Interviewer Expects
  • Recognizes transitive matching as connected components
  • Uses union find (or BFS over a record attribute graph) with an attribute to first-owner map
  • Normalizes values (trim, lowercase) and skips empty or null attributes
  • Matches on (attribute name, value) pairs, not raw values alone
  • Returns deterministic output ordering
  • Analyzes near linear time with path compression and union by rank
Key Topics to Cover
union find
hashing
connected components
data normalization
identity 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
  • A shared help desk phone number links hundreds of people. How do you stop over-merging?
  • How would you support incremental imports without recomputing everything?
  • Some attributes should only match if two of them agree. How does the design change?
  • How would you undo a bad merge an admin reports?
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

Records: (record_id, {attr: value}). Two records are the same person if any (attr, normalize(value)) pair is equal; matching is transitive (A matches B by employee_id, B matches C by phone, so A, ...

High-Level Design

Treat each record as a node. Keep owner[(attr, value)] = first record that had it. When another record has the same key, union it with the owner. This creates at most one union per attribute occurre...


Submit Your Answer
Markdown supported