Skip to content

929. Unique Email Addresses#15

Open
X-XsleepZzz wants to merge 2 commits intomainfrom
X-XsleepZzz-patch-4
Open

929. Unique Email Addresses#15
X-XsleepZzz wants to merge 2 commits intomainfrom
X-XsleepZzz-patch-4

Conversation

@X-XsleepZzz
Copy link
Copy Markdown
Owner

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 '+'.

For example, in "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.

For example, "alice.z@leetcode.com" and "alicez@leetcode.com" forward to the same email address.
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.

For example, "m.y+name@email.com" will be forwarded to "my@email.com".
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.

url: https://leetcode.com/problems/unique-email-addresses/description/

Added problem description and rules for unique email addresses.
Added detailed explanation and examples for unique email addresses problem. Included Python solution with time and space complexity analysis.
```py
class Solution:
def numUniqueEmails(self, emails: List[str]) -> int:
normalized_set = set()
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

メールアドレスの正規化という文脈では、canonicalize という単語もよく見かけます。
_set_emails の方が、何が入っているか分かりやすそうです。

Comment on lines +124 to +125
plus_ignored_local_name = re.sub(r"\+.*", "", local_name)
dot_removed_local_name = re.sub(r"\.", "", plus_ignored_local_name)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

個人的には、正規表現よりも split("+"), replace(".", "") の方が読みやすかったです。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants