Open
Conversation
huyfififi
reviewed
Mar 15, 2026
| break; | ||
| }; | ||
|
|
||
| if num > i32::MAX / 10 || num == i32::MAX / 10 && digit > i32::MAX % 10 { |
There was a problem hiding this comment.
代替案が提示できるわけではないのですが、positive に対しては単純に overflow をチェックしているように読める一方で、negative 側は-2147483648 を扱う関係で同じ意味では読めず、少し意図が分かりにくいように感じました。
ここの条件をoverflowチェックだと読み飛ばしてしまってから最後まで進んだ際、 positiveの場合 i32::MAXが最後まで許容されている一方で、negativeの場合 i32::MIN が early return される形になっており、挙動が対称でないので少し混乱しやすいように感じました。
(私の読解に問題があるような気もしますが😓)
| 参考にした解法 | ||
| https://github.com/hayashi-ay/leetcode/pull/69/changes#diff-f2b395d63173ac2f2d3c547e8f9e8e07c9acfbeb6b5da935bb28d83d8bcc7a04R145 | ||
| https://github.com/Yoshiki-Iwasa/Arai60/pull/64/changes#diff-dbf5e75b50aa4257946026d6539860be248a58856e1b457b4d37445059b05857R21 | ||
| if num > i32::MAX / 10 || num == i32::MAX / 10 && digit > i32::MAX % 10 |
There was a problem hiding this comment.
ここは自分で解いた時あまり深く理解できずに飛ばしてしまったところだったので、勉強になりました!
oda
reviewed
Mar 16, 2026
| break; | ||
| }; | ||
|
|
||
| if num > i32::MAX / 10 || num == i32::MAX / 10 && digit > i32::MAX % 10 { |
There was a problem hiding this comment.
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.
問題: 8. String to Integer (atoi)
次に解く問題: 6. Zigzag Conversion
ファイルの構成:
./src/bin/<各ステップ>.rs