Skip to content

929. Unique Email Addresses#14

Open
TakayaShirai wants to merge 1 commit intomainfrom
929_unique_email_addresses
Open

929. Unique Email Addresses#14
TakayaShirai wants to merge 1 commit intomainfrom
929_unique_email_addresses

Conversation

@TakayaShirai
Copy link
Copy Markdown
Owner

@TakayaShirai TakayaShirai self-assigned this Jan 8, 2026
int maxAtCount = 1;
int minAtCount = 1;

if (!(minAtCount <= atCount && atCount <= maxAtCount)) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

minmax を定義しているのは拡張性を意識してでしょうか。単に @ がひとつかどうかを調べても良さそうに思いました。

Suggested change
if (!(minAtCount <= atCount && atCount <= maxAtCount)) {
if (atCount != 1) {

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

min と max を定義しているのは拡張性を意識してでしょうか

ご指摘のとおり拡張性を意識して定義していました。ただ、メールアドレスの特性上"@"が複数許容されることはほとんどなさそうなため、単に一つだけの方が良さそうです。

}

bool isValidEmail(String email) {
final parts = email.split('@');
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[fyi]
本問の制約を超えていますが、local にクオートした @ を含むのは正当なようです。
https://datatracker.ietf.org/doc/html/rfc5322#section-3.4.1

return false;
}

return domain != domainTail;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

個人的には、「domainTailの前に少なくとも1文字を含む」という条件が明に書かれていたほうが分かりやすいと思いました。

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

確かに伝わりづらいですね…。「domainTailの前に少なくとも1文字を含む」という条件を書き直すとすると例えば、domain.length - domainTail.length >= 1などでしょうか。

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

domain.length - domainTail.length >= 1

良さそうです!

Comment on lines +222 to +234
for (int i = 0; i < originalLocal.length; i++) {
String char = originalLocal[i];

if (char == '+') {
break;
}

if (char == '.') {
continue;
}

buffer.write(char);
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

dart未経験者として、String.split()String.replaceAll() ではなく、一文字ずつ見ていく方式を取った判断がメモに書いてあると良いと思いました。

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