Skip to content

Update AddTwoNumbers.md#18

Open
Apo-Matchbox wants to merge 1 commit intomemo.mdfrom
AddTwoNumbers
Open

Update AddTwoNumbers.md#18
Apo-Matchbox wants to merge 1 commit intomemo.mdfrom
AddTwoNumbers

Conversation

@Apo-Matchbox
Copy link
Owner

```

##Step2 8/1 10:50
##Step2
Copy link

Choose a reason for hiding this comment

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

マークダウンとして装飾するには##の後に半角空白を入れて## step2のようにしないとうまく表示されないです。vscodeなどであればmdファイルのプレビュー(右上の虫眼鏡マーク)ができると思うので確認してみるとよいと思います。

Copy link
Owner Author

Choose a reason for hiding this comment

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

コメントありがとうございます。
一度previewを確認するなどして、仕様も都度修正致します。

carryover = value / 10;
value %= 10;
carryover = digitSum / 10;
digitSum %= 10;
Copy link

@maeken4 maeken4 Aug 6, 2025

Choose a reason for hiding this comment

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

この段階でdigitSumは意味的にはdigitSumではなくなってしまうので、別の変数に入れるか、この後直接
result_tail->next = new ListNode(digitSum % 10);
としてもよいように思いました。

Copy link

@maeken4 maeken4 left a comment

Choose a reason for hiding this comment

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

githubのプルリクはマージ先のブランチに対する差分に対して行うものだと思うのですが、マージ先でも当問題が進行しておりどの部分がレビュー対象なのかわかりにくく感じました。皆さんのブランチの使い方を見るに、
問題を解く前にブランチを切る→マージ先はmainブランチとして、差分として各Leetcodeの問題を解いたコードやメモをレビュー対象とする、というのが多いと思います。

@Apo-Matchbox
Copy link
Owner Author

githubのプルリクはマージ先のブランチに対する差分に対して行うものだと思うのですが、マージ先でも当問題が進行しておりどの部分がレビュー対象なのかわかりにくく感じました。皆さんのブランチの使い方を見るに、 問題を解く前にブランチを切る→マージ先はmainブランチとして、差分として各Leetcodeの問題を解いたコードやメモをレビュー対象とする、というのが多いと思います。

コメントありがとうございます。
読みずらいものとなってしまい申し訳ございません。もう一度gitの使い方確認致します。

ListNode* addTwoNumbers(ListNode* l1, ListNode* l2) {
ListNode dummy_head = ListNode();
ListNode* result_tail = &dummy_head;
int carryover = 0;
Copy link

Choose a reason for hiding this comment

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

carry で、コンピューター用語で繰り上げを表します。こちらのほうがシンプルだと思います。 carryover でも十分伝わると思いますので、好みの問題だと思います。

int carryover = 0;
while (l1 || l2 || carryover) {
int value = carryover;
int digitSum = carryover;
Copy link

Choose a reason for hiding this comment

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

snake_case と lowerCamel が混ざっているのが気になりました。

参考までにスタイルガイドへのリンクを貼ります。

https://google.github.io/styleguide/cppguide.html#Variable_Names

The names of variables (including function parameters) and data members are snake_case (all lowercase, with underscores between words).

上記のスタイルガイドは唯一絶対のルールではなく、複数あるスタイルガイドの一つに過ぎないということを念頭に置くことをお勧めします。また、所属するチームにより何が良いとされているかは変わります。自分の中で良い書き方の基準を持ちつつ、チームの平均的な書き方で書くことをお勧めいたします。

Copy link
Owner Author

Choose a reason for hiding this comment

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

コメントありがとうございます。
sanke_caseとlowerCamelという言い回しがあるんですね。
変数、関数、classなどそれぞれでの命名ルールも参考にします。

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