Skip to content

Update 82. Remove Duplicates from Sorted List II.md#12

Open
Apo-Matchbox wants to merge 1 commit intoCreate-82.-Remove-Duplicates-from-Sorted-List-IIfrom
82.-Remove-Duplicates-from-Sorted-List-II
Open

Update 82. Remove Duplicates from Sorted List II.md#12
Apo-Matchbox wants to merge 1 commit intoCreate-82.-Remove-Duplicates-from-Sorted-List-IIfrom
82.-Remove-Duplicates-from-Sorted-List-II

Conversation

@Apo-Matchbox
Copy link
Copy Markdown
Owner

}
node->next = next_node; // 重複をスキップ
}
else {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

elseで改行されていると少し読み辛いと感じました。
参考にこの辺りのガイドを共有いたします。
https://google.github.io/styleguide/cppguide.html#Formatting_Looping_Branching

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

スタイルは色々な流派があります。改行の単位まで場合によってはこだわります。
ただ、優先順位としてはデザイン、どこにどう配置するかなどのほうが重要度はだいぶ上です。
https://discord.com/channels/1084280443945353267/1366778718705553520/1377689037208289471

スタイルガイドについてはコメント集に少し書いたかと思います。

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.

@Ryotaro25
スタイルの共有ありがとうございます。
私のスタイルは、提示いただいたgoogleのものを参考に基準を養っていきたいと思ってましたが、確認できていませんでした。頂くコメントを予測して、振り返ることを忘れずにしたいと思います。

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.

@oda
コメントありがとうございます。
こちらのdiscord確認できていませんでした。レビューの仕方と見るべきポイント確認しておきます。

bool has_duplicates = next_node->next && next_node->val == next_node->next->val;

if (has_duplicates) {
int dup_val = next_node->val; // 重複部分をすべて delete
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

次のNodeがもつ値を変数に置かなくてもいいのかなと感じました。

ListNode* next_node = head;

while (node && next_node) {
bool has_duplicates = next_node->next && next_node->val == next_node->next->val;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

こちらに関しても変数に置かなくてもいいのかなと思いました。

他の方のGitHubを確認
*https://github.com/maeken4/Arai60/pull/4/commits/32508ad2702b7c64d55f45023bfd816fa33358c3
 maeken さん 
 野田さんのコメント:std::unique_ptr や std::shared_ptr の使い方を確認:https://cpprefjp.github.io/reference/memory/unique_ptr.html
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

ご存知でしたらすみません。Effective C++にこの辺りのことがいくつか書かれております。
この会でも何度か紹介されておりますので共有いたします。

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.

@Ryotaro25
コメントありがとうございます!
リンクが添付されてないみたいです。お手隙で共有頂けたらと思います。

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

すみませんこちらは書籍になります🙇
https://amzn.asia/d/1fDsGyd

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