#K89242. Duplicate Emails Finder
Duplicate Emails Finder
Duplicate Emails Finder
In this problem, you are given an integer ( n ) followed by ( 2n ) lines. Each person has exactly two email address entries. Each line contains a name and an email address separated by a space. Your task is to determine if there are any duplicate email addresses that appear for more than one person. If such duplicates exist, output the names (without repetition) of all persons who are associated with any duplicate email, in alphabetically sorted order (one per line). Otherwise, print "No duplicates".
Input Format:
- The first line contains an integer \( n \), representing the number of persons.
- The following \( 2n \) lines each contain a string and an email address separated by a space.
Note: It is guaranteed that the input is provided via stdin
and the output should be written to stdout
.
inputFormat
The first line of input contains an integer ( n ) (the number of persons). This is followed by ( 2n ) lines, where each line contains a name and an email address separated by a space.
outputFormat
If there is at least one email address that appears more than once among all the entries, output the distinct names associated with such emails in alphabetical order, each on a separate line. If no duplicate email addresses are found, print "No duplicates".## sample
4
Alice alice@example.com
Alice alice.smith@example.com
Bob bob@example.com
Bob bob.smith@example.com
Charlie charlie@example.com
Charlie charlie123@example.com
David david@example.com
David david.smith@example.com
No duplicates