Accounts Merge
A medium-tier problem at 60% community acceptance, tagged with Array, Hash Table, String. Reported in interviews at Meta and 7 others.
You get a list of accounts where each account is a list of emails, and some emails belong to the same person across accounts. You need to merge all accounts that share at least one email and return the merged accounts with emails sorted. Meta, LinkedIn, and Palantir have all asked this. It's a medium-difficulty problem but the graph-traversal pattern trips up candidates who don't immediately see it's a grouping problem. The acceptance rate sits around 60%, which means solid preparation usually gets you past it. If you blank on the union-find or DFS connection during your live OA, StealthCoder solves it invisibly in seconds.
Companies that ask "Accounts Merge"
Accounts Merge is the kind of problem that decides whether you pass. StealthCoder reads the problem on screen and surfaces a working solution in under 2 seconds. Invisible to screen share. The proctor sees nothing. Made for the engineer who has done the work but might still blank with a webcam pointed at him.
Get StealthCoderThe trick is recognizing this as a connected-components problem, not a string-matching one. Emails are nodes, accounts are edges. Any two emails in the same account belong to the same person. You build a graph, then traverse to find all connected components. Most candidates try hash tables first and get lost in nested loops. Union Find is the elegant approach: union all emails in each account, then group by parent and sort. DFS or BFS work too if you build an adjacency list correctly. The common pitfall is assuming each email appears once, or trying to match substrings instead of treating emails as unique identifiers. Sort the final merged emails alphabetically so output matches expected. This problem shows up frequently at Meta and LinkedIn's second-round interviews. If you haven't drilled union-find patterns before, this is exactly where StealthCoder becomes your safety net during screen share.
Pattern tags
You know the problem.
Make sure you actually pass it.
Accounts Merge recycles across companies for a reason. It's medium-tier, and most candidates blank under the timer. StealthCoder is the hedge: an AI overlay invisible during screen share. It reads the problem and surfaces a working solution in under 2 seconds. Made for the engineer who has done the work but might still blank with a webcam pointed at him. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Accounts Merge interview FAQ
Is union-find really necessary or can I just use DFS?+
Both work. Union-find is cleaner and faster for large datasets. DFS requires building an adjacency list, which costs extra memory and logic. Neither is wrong, but union-find shows better algorithmic maturity. This problem is reported by 8 companies including Meta and LinkedIn, so either approach passes if it's correct.
What's the acceptance rate saying about this problem's difficulty?+
At 60% acceptance, it's genuinely medium. Not a gimme, not a wall. Most failures come from graph-construction logic, not the concept itself. Candidates who see the connected-components pattern early usually solve it. Those who treat it as a pure string problem struggle.
Do I need to handle duplicate emails within an account?+
Input constraints aren't specified here, but assume no duplicates within an account. If they exist, your union-find or graph handles it naturally by idempotence. Always check problem statement constraints, but don't over-engineer for edge cases that aren't mentioned.
Why is sorting required in the output?+
The problem asks for merged accounts with emails sorted alphabetically. This is a detail that catches people who implement the merge logic correctly but forget the final sort step. It's a one-liner but costs your submission if omitted. Always re-read output format before submitting.
How does this relate to topics like Array and Hash Table?+
Array is the input format. Hash Table helps map emails to account indices or track parent pointers in union-find. String operations identify and deduplicate emails. The core algorithm is union-find or graph traversal, but all these topics touch the solution at different layers.
Want the actual problem statement? View "Accounts Merge" on LeetCode →