Conversation
Rinta-Rinta
reviewed
Jan 11, 2026
Comment on lines
+79
to
+91
| while (node != nullptr) { | ||
| if (node->next != nullptr && node->val == node->next->val) { | ||
| int dupVal = node->val; | ||
| while (node != nullptr && node->val == dupVal) { | ||
| node = node->next; | ||
| } | ||
| unique->next = node; | ||
| } else { | ||
| node = node->next; | ||
| unique = unique->next; | ||
| } | ||
| } | ||
| return dummy.next; |
There was a problem hiding this comment.
Rinta-Rinta/LeetCode_arai60#3 (comment)
https://discord.com/channels/1084280443945353267/1195700948786491403/1196701558382018590
処理が分岐する際に、処理の長さや簡単さによってはif-elseで並べずにcontinueやbreakで抜ける方が、
分かりやすい場合もありそうです。
Owner
Author
There was a problem hiding this comment.
なるほど、大事なご指摘だと思います。
特にシンプルな処理の場合は、先にcontinueで抜けた方が可読性が上がる場面も多いと感じました。
ありがとうございます🙏
oda
reviewed
Jan 11, 2026
Comment on lines
+23
to
+24
| - headが重複している場合のエッジケースの考慮が必要 | ||
| - head一つのみのときの処理が必要 |
There was a problem hiding this comment.
この方法でもできるはずですが、確かに大変です。Step 2の方法で、重複していない先頭が見つかるまでは別のループを前につけるか、そうでなければ、保存するノードが見つかったときに、先頭が見つかっているかいなかで条件分岐します。
Owner
Author
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.
82. Remove Duplicates from Sorted List II