Skip to content

83. Remove Duplicates from Sorted List#4

Open
hemispherium wants to merge 2 commits intomainfrom
0083-remove-duplicates-from-sorted-list
Open

83. Remove Duplicates from Sorted List#4
hemispherium wants to merge 2 commits intomainfrom
0083-remove-duplicates-from-sorted-list

Conversation

@hemispherium
Copy link
Owner

@hemispherium hemispherium self-assigned this Dec 10, 2025
@@ -0,0 +1,12 @@
### step1

単純に、重複していないnodeにnextを付けかえればいいのではと思い、それを実装してた解けた。

Choose a reason for hiding this comment

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

Nodeの付け替えだけでなく、新たに構築する方法を見てもいいかもです。

Comment on lines +15 to +21
while (curr != nullptr && curr->next != nullptr) {
if (curr->val == curr->next->val) {
curr->next = curr->next->next;
} else {
curr = curr->next;
}
}
Copy link

@fv17 fv17 Dec 10, 2025

Choose a reason for hiding this comment

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

ループの方法も別解(二重ループ版)があったので見てみると面白いかもしれません。
この問題以外でも良く出てくるので、もし他の問題でもまだ試していなかったら是非。
もしくは、後続でも出てくる気がするのでそちらでも

Copy link
Owner Author

Choose a reason for hiding this comment

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

承知しました!

Copy link
Owner Author

Choose a reason for hiding this comment

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

solution2.cppというファイルで二重ループ版の別解を追加しました。

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.

3 participants