Back to DSA sheet

Unique Email Addresses

EasyArrays

Each email has a local part and a domain split by '@'. In the local part, dots are ignored and everything from the first '+' onward is ignored. The domain is unchanged. Count how many distinct delivery addresses a list of emails maps to.

Input format (stdin): the first line has n. Each of the next n lines is one email. Output the number of unique normalised addresses.

Examples
Input: 3 test.email+alex@leetcode.com test.e.mail+bob.cathy@leetcode.com testemail+david@lee.tcode.com
Output: 2
The first two normalise to the same address; the third differs by domain.
Constraints
  • 1 <= n <= 100
  • Each email has exactly one '@'
Sheets
NeetCode 250
unique-email-addresses.cpp2 sample tests
Loading editor
Test results

Run the sample tests to check your solution against expected output.

Custom input (stdin)
Output

Run your code to see its output.