Open
Conversation
nanae772
reviewed
Sep 22, 2025
| for email in emails: | ||
| normalized_email = "" | ||
| has_plus_sign = False | ||
| for i, s in enumerate(email): |
There was a problem hiding this comment.
文字を表す変数にsを使われたのはなぜでしょうか?
個人的にはsは文字列という印象があるので、c, chあたりにするかなと思いました。
Owner
Author
There was a problem hiding this comment.
ありがとうございます。確かにこれは c のほうが良いですね。
Comment on lines
+31
to
+32
| if s == ".": | ||
| continue |
|
|
||
| normalized_emails.add(normalized_email) | ||
|
|
||
| print(normalized_emails) |
Comment on lines
+116
to
+117
| local_part = local_part.split("+")[0] | ||
| local_part = local_part.replace(".", "") |
There was a problem hiding this comment.
以下のように一行で書くこともできそうです
Suggested change
| local_part = local_part.split("+")[0] | |
| local_part = local_part.replace(".", "") | |
| local_part = local_part.split("+")[0].replace(".", "") |
| local_part, domain_part = email.split("@") | ||
| local_part = local_part.split("+")[0] | ||
| local_part = local_part.replace(".", "") | ||
| return local_part + "@" + domain_part |
There was a problem hiding this comment.
以下のようにf-stringで書く方法もあります、個人的には形が分かりやすいのでf-stringの方が好みです
Suggested change
| return local_part + "@" + domain_part | |
| return f"{local_part}@{domain_part}" |
akmhmgc
reviewed
Sep 23, 2025
| return len(normalized_emails) | ||
| ``` | ||
| - 解答時間: 20:14 | ||
| - 時間計算量: $O(n^2)$ |
There was a problem hiding this comment.
文字列の個数と文字の長さは分けた方が良いのでO(M * N)などの記載が良いと思います
| class Solution: | ||
| def numUniqueEmails(self, emails: List[str]) -> int: | ||
| def canonicalize(email: str) -> str: | ||
| local_part, domain_part = email.split("@") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
929. Unique Email Addresses
次回予告 : 252. Meeting Rooms