Re: 2.Add Two Numbers#15
Open
philip82148 wants to merge 1 commit into
Open
Conversation
nodchip
reviewed
Apr 23, 2025
| public: | ||
| ListNode* addTwoNumbers(ListNode* l1, ListNode* l2) { | ||
| int carry = 0; | ||
| ListNode sentinel, *node = &sentinel; |
There was a problem hiding this comment.
同一の行で値型やポインター型等の型を混ぜて宣言すると、読みづらく感じます。分けて書いたほうがよいと思います。
https://google.github.io/styleguide/cppguide.html#Pointer_and_Reference_Expressions
It is allowed (if unusual) to declare multiple variables in the same declaration, but it is disallowed if any of those have pointer or reference decorations. Such declarations are easily misread.
oda
reviewed
Apr 23, 2025
| public: | ||
| ListNode* addTwoNumbers(ListNode* l1, ListNode* l2) { | ||
| int carry = 0; | ||
| ListNode sentinel, *node = &sentinel; |
5ky7
reviewed
Apr 23, 2025
| sum += l2->val; | ||
| l2 = l2->next; | ||
| } | ||
| node = node->next = new ListNode(sum % 10); |
| carry = sum / 10; | ||
| } | ||
| return sentinel.next; | ||
| } |
There was a problem hiding this comment.
以前解かれていた 5.cpp のファイルには空行がいくつかありましたが、それらをなくしたこちらのコードの方が読みやすく感じました。
|
読みやすくて良いと思います! |
Satorien
reviewed
Apr 26, 2025
| // <時間> | ||
| // 5分 | ||
| // <感想> | ||
| // 久しぶりに書き直したら5.cppとほぼ同じものが出来上がった。 |
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.
こちらは以前解いたものの解きなおしになります
前回のPRはこちらです: #2
問題
https://leetcode.com/problems/search-insert-position/description/
補足
<番号>r.cppは<番号>.cppを書きなおしたものになっています。(微妙に違うか同じです)