You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Two accounts belong to the same person if they share at least one common email.
22
-
Even if two accounts have the same name, they might belong to different people, so merging should only be based on shared emails. Each person can have multiple accounts, and all merged accounts should have the same name.
23
-
24
-
25
-
*
26
-
*
27
-
*/
28
2
importjava.util.List;
29
3
importjava.util.ArrayList;
30
4
importjava.util.Arrays;
31
5
importjava.util.Collections;
32
6
publicclassMergeAccounts {
7
+
/**
8
+
* Merges accounts that share at least one common email address.
9
+
*
10
+
* <p>This method takes a list of accounts, where each account is represented as a list of strings:
11
+
* the first element is the account holder's name, followed by one or more email addresses.
12
+
* It merges accounts that share both the same name and at least one email address into a single list,
13
+
* removing duplicates and redundant entries.</p>
14
+
*
15
+
* @param inputList a list of accounts, each represented as [name, email1, email2, ...]
0 commit comments