A newsletter's signup form logs every submission as a brand-new record, each tagged with a unique record id and the email address that was entered. Because visitors could resubmit the form (for example, after a network hiccup), some email addresses end up appearing in multiple records even though the form assigns a fresh id to every submission. Given the raw signup log, find every email address that appears in two or more records.
Example 1
Input
5 1 a@x.com 2 b@x.com 3 a@x.com 4 c@x.com 5 b@x.com
Expected
2 a@x.com b@x.com
Explanation
a@x.com appears in records 1 and 3, and b@x.com appears in records 2 and 5, so both are duplicates. c@x.com appears only once (record 4), so it is excluded. Sorted ascending, a@x.com comes before b@x.com, giving output 2 followed by a@x.com then b@x.com.
Example 2
Input
3 10 alice@mail.com 20 bob@mail.com 30 carol@mail.com
Expected
0
Explanation
Every email address here appears exactly once, so there are no duplicates. The output is just the single line 0, with no further lines.
Ready to solve this?
Sign in to open the editor, run your code against the sample tests, and submit against the full test suite.
Sign in to solve →