Tap here to switch tabs
Problem
Submissions

Problem: Unique Email Addresses

med
30 min
Try to solve the Unique Email Addresses problem.

Statement

Every valid email consists of a local name and a domain name, separated by the '@' sign. Besides lowercase letters, the email may contain one or more '.' or '+' characters.

For example, in the email "alice@leetcode.com", "alice" is the local name, and "leetcode.com" is the domain name.

If you add periods '.' between some characters in the local name part of an email address, mail sent there will be forwarded to the same address without dots in the local name. Note that this rule does not apply to domain names.

If you add a plus '+' in the local name, everything after the first plus sign will be ignored. This allows certain emails to be filtered. Note that this rule does not apply to domain names.

It is possible to use both of these rules at the same time.

Given an array of strings emails where we send one email to each emails[i], return the number of different addresses that actually receive mails.

Constraints:

  • 1≤1 \leq emails.length ≤100\leq 100

  • 1≤1 \leq emails[i].length ≤100\leq 100

  • emails[i] consists of lowercase English letters, '+', '.', and '@'.

  • Each emails[i] contains exactly 11 '@' character.

  • All local and domain names are non-empty.

  • Local names do not start with a '+' character.

  • Domain names end with the ".com" suffix.

  • Domain names must contain at least 11 character before the ".com" suffix.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Unique Email Addresses

med
30 min
Try to solve the Unique Email Addresses problem.

Statement

Every valid email consists of a local name and a domain name, separated by the '@' sign. Besides lowercase letters, the email may contain one or more '.' or '+' characters.

For example, in the email "alice@leetcode.com", "alice" is the local name, and "leetcode.com" is the domain name.

If you add periods '.' between some characters in the local name part of an email address, mail sent there will be forwarded to the same address without dots in the local name. Note that this rule does not apply to domain names.

If you add a plus '+' in the local name, everything after the first plus sign will be ignored. This allows certain emails to be filtered. Note that this rule does not apply to domain names.

It is possible to use both of these rules at the same time.

Given an array of strings emails where we send one email to each emails[i], return the number of different addresses that actually receive mails.

Constraints:

  • 1≤1 \leq emails.length ≤100\leq 100

  • 1≤1 \leq emails[i].length ≤100\leq 100

  • emails[i] consists of lowercase English letters, '+', '.', and '@'.

  • Each emails[i] contains exactly 11 '@' character.

  • All local and domain names are non-empty.

  • Local names do not start with a '+' character.

  • Domain names end with the ".com" suffix.

  • Domain names must contain at least 11 character before the ".com" suffix.