Conversation
| int maxAtCount = 1; | ||
| int minAtCount = 1; | ||
|
|
||
| if (!(minAtCount <= atCount && atCount <= maxAtCount)) { |
There was a problem hiding this comment.
min と max を定義しているのは拡張性を意識してでしょうか。単に @ がひとつかどうかを調べても良さそうに思いました。
| if (!(minAtCount <= atCount && atCount <= maxAtCount)) { | |
| if (atCount != 1) { |
There was a problem hiding this comment.
min と max を定義しているのは拡張性を意識してでしょうか
ご指摘のとおり拡張性を意識して定義していました。ただ、メールアドレスの特性上"@"が複数許容されることはほとんどなさそうなため、単に一つだけの方が良さそうです。
| } | ||
|
|
||
| bool isValidEmail(String email) { | ||
| final parts = email.split('@'); |
There was a problem hiding this comment.
[fyi]
本問の制約を超えていますが、local にクオートした @ を含むのは正当なようです。
https://datatracker.ietf.org/doc/html/rfc5322#section-3.4.1
| return false; | ||
| } | ||
|
|
||
| return domain != domainTail; |
There was a problem hiding this comment.
個人的には、「domainTailの前に少なくとも1文字を含む」という条件が明に書かれていたほうが分かりやすいと思いました。
There was a problem hiding this comment.
確かに伝わりづらいですね…。「domainTailの前に少なくとも1文字を含む」という条件を書き直すとすると例えば、domain.length - domainTail.length >= 1などでしょうか。
There was a problem hiding this comment.
domain.length - domainTail.length >= 1
良さそうです!
| for (int i = 0; i < originalLocal.length; i++) { | ||
| String char = originalLocal[i]; | ||
|
|
||
| if (char == '+') { | ||
| break; | ||
| } | ||
|
|
||
| if (char == '.') { | ||
| continue; | ||
| } | ||
|
|
||
| buffer.write(char); | ||
| } |
There was a problem hiding this comment.
dart未経験者として、String.split() や String.replaceAll() ではなく、一文字ずつ見ていく方式を取った判断がメモに書いてあると良いと思いました。
解いた問題:https://leetcode.com/problems/unique-email-addresses/description/
次に解く問題:https://leetcode.com/problems/first-unique-character-in-a-string/description/