Implementation details:
Email ownership: Map each email to the first account that owns it
Union on collision: If an email is already owned, union the accounts
Collect by root: After all unions, group emails by their root account
Sort and format: Each result entry is [name, sorted emails] Edge cases: - Same name, different people (accounts don't merge unless they share an email) - Single account (no merging needed) - All accounts merge into one Time: for unions where is average emails per account, plus for sorting. Space: for email map and result.