Skip to content
We areTOP 1%

Accounts Merge

MediumLeetCodeUnion-Find (DSU)
Solve on LeetCode(opens in a new tab)
Track your progress
First attempt
Re-solve after a few days
Final pass before interviews
Approach hintTry it first, then reveal

Map each email to the first account index that contains it and union any later account with that index. Then group emails by root, sort each group, and prepend the owner's name.

More in Union-Find (DSU)

Union-Find (DSU) questions
#ProblemPlatformDifficultyOpen1st1st Visit2nd2nd VisitRevRevise
1Redundant ConnectionLeetCodeMedium Solve Redundant Connection on LeetCode (opens in a new tab)
2Satisfiability of Equality EquationsLeetCodeMedium Solve Satisfiability of Equality Equations on LeetCode (opens in a new tab)
3Number of Operations to Make Network ConnectedLeetCodeMedium Solve Number of Operations to Make Network Connected on LeetCode (opens in a new tab)
4News DistributionCodeforcesMedium 1400Solve News Distribution on Codeforces (opens in a new tab)
5Accounts MergeLeetCodeMedium Solve Accounts Merge on LeetCode (opens in a new tab)
6Most Stones Removed with Same Row or ColumnLeetCodeMedium Solve Most Stones Removed with Same Row or Column on LeetCode (opens in a new tab)
7Bear and Friendship ConditionCodeforcesMedium 1500Solve Bear and Friendship Condition on Codeforces (opens in a new tab)
8SocksCodeforcesMedium 1600Solve Socks on Codeforces (opens in a new tab)
9Destroying ArrayCodeforcesMedium 1600Solve Destroying Array on Codeforces (opens in a new tab)
10Path QueriesCodeforcesHard 1800Solve Path Queries on Codeforces (opens in a new tab)
11Making A Large IslandLeetCodeHard Solve Making A Large Island on LeetCode (opens in a new tab)
12Remove Max Number of Edges to Keep Graph Fully TraversableLeetCodeHard Solve Remove Max Number of Edges to Keep Graph Fully Traversable on LeetCode (opens in a new tab)

Sign in to track your progress

Your checkboxes, streak and activity heatmap are saved to your account and sync across devices. It is free.
Sign in with email

New here? Create an account