A recurring meetup group keeps a signup roster. Every signup has a unique registration id (a positive integer, not necessarily assigned in order) and an email address, exactly as the attendee typed it (case matters — two emails that differ only in letter case count as different addresses). Because the same person sometimes fills out the form more than once, the organizers want to keep, for every email address that appears, only the signup with the smallest registration id, and purge every other signup sharing that same email address. Signups whose email address is unique in the roster are never purged.
Given the roster, determine exactly which registration ids must be purged.
id email, where id is the registration id and email is the signup's email address (a token with no whitespace).Example 1
Input
4 1 alice@example.com 2 alice@example.com 3 bob@example.com 4 alice@example.com
Expected
2 2 4
Explanation
alice@example.com appears with ids 1, 2 and 4; the smallest is 1, so ids 2 and 4 must be purged. bob@example.com appears only with id 3, so it is never purged. The purged ids, in ascending order, are 2 and 4.
Example 2
Input
3 5 a@x.com 6 b@x.com 7 c@x.com
Expected
0
Explanation
Every email address on the roster is unique, so no signup shares its email with another and nothing needs to be purged: k is 0 and the second line is empty.
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 →