Attribute Anonymous and Identified Events to Merged User Profiles

Last updated: November 29, 2026

Quick Overview

Given a stream of events keyed by distinct_id and a list of merge records linking anonymous device IDs to logged-in user IDs, return event counts per resolved user, where merges are transitive and each cluster reports under its identified ID.

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

0

0

0 solved


Given a stream of events keyed by distinct_id and a list of merge records linking anonymous device IDs to logged-in user IDs, return event counts per resolved user, where merges are transitive and each cluster reports under its identified ID.

Mixpanel's identity management stitches pre-login device activity to the user who later signs in, so funnels from anonymous landing page to paid conversion count as one person. The question checks union-find fluency plus judgment about which ID becomes canonical.

What the Interviewer Expects
  • Model merges as an undirected graph and recognize union-find
  • Use path compression and union by size
  • Choose a canonical ID per cluster (the identified user, not an arbitrary root)
  • Apply all merges before attributing, or explain retroactive attribution
  • Discuss limits such as capping cluster size to stop runaway merges
Key Topics to Cover
union-find
identity resolution
graph connectivity
canonical IDs
retroactive attribution
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 kiosk device logs in as 500 different users: how do you prevent one giant cluster?
  • Merges arrive after events were already counted: how do you correct historical reports without rewriting them?
  • How would you support unmerging a mistaken link?
  • How do you distribute the identity graph across shards?
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

Events: list of (distinct_id, name). Merges: list of (anon_id, user_id) where the second element is an identified ID. Merges are transitive: anon1 to u42 and anon2 to u42 put all three together. O...

High-Level Design

Union-find over all IDs. Each root stores cluster size and a canonical identified ID. On union, attach the smaller tree under the larger and keep whichever canonical ID exists (first identified wins)....


Submit Your Answer
Markdown supported

Related Questions