Accounts Merge
Solve this the way you would in the interview: out loud, on a timer, with an AI interviewer asking follow-ups while you code. You get a scored report at the end.
Practice this as a mock interviewFree to start, no account neededProblem
You are given a list accounts. Each accounts[i] is a list of strings: the first string is a person's name and the rest are email addresses belonging to that account.
Two accounts belong to the same person if they share **at least one** email address; this relation is transitive (if A shares an email with B and B shares one with C, all three are one person). Two accounts with the same name but no shared-email chain are **different** people. Every account of one person carries the same name.
Return the merged accounts. Each merged account is [name, email1, email2, ...] with every distinct email listed once, sorted in ascending ASCII (plain string) order. The merged accounts themselves may be returned in any order.
Examples
Constraints
- 1 <= accounts.length <= 1000
- 2 <= accounts[i].length <= 10
- 1 <= accounts[i][j].length <= 30
- Names consist of English letters; emails are lowercase letters, digits, `_`, `.` and `@`
What the interviewer grades
A correct solution is one of five scores. The report also grades problem understanding (did you clarify inputs and edge cases before coding), problem solving, communication while you work, code quality, and testing. See a sample report, or read up on the pattern in the lessons.