Accounts Merge (LeetCode 721)
Asked in the Coding Round 2 stage. Given account records containing a name followed by email addresses, merge accounts that share at least one email, including transitively connected accounts.
accounts is a list of lists of strings. Each inner list has the form [name, email1, email2, ...]. Return merged lists in the same format, with emails sorted lexicographically. The name is the first field of each merged list; output group order is arbitrary.
def accounts_merge(accounts):