Open
Conversation
nodchip
reviewed
Nov 14, 2025
| if (nums.size() == 1) { | ||
| return nums[0]; | ||
| } | ||
| vector<int> sums(nums.size()); |
There was a problem hiding this comment.
読み手にとって読みやすくするため、処理の区切りを視覚的に分かりやすくする目的で、適宜空行を入れることをおすすめします。
参考までにスタイルガイドへのリンクを貼ります。
Use vertical whitespace sparingly; unnecessary blank lines make it harder to see overall code structure. Use blank lines only where they aid the reader in understanding the structure.
https://google.github.io/styleguide/cppguide.html#Vertical_Whitespace
上記のスタイルガイドは唯一絶対のルールではなく、複数あるスタイルガイドの一つに過ぎないということを念頭に置くことをお勧めします。また、所属するチームにより何が良いとされているかは変わります。自分の中で良い書き方の基準を持ちつつ、チームの平均的な書き方で書くことをお勧めいたします。
|
|
||
| - 書いてみた感じ、やはりstep1の方が素直でわかりやすく感じたのでstep3ではそれで書く。 | ||
|
|
||
| ## Step3 |
naoto-iwase
reviewed
Nov 15, 2025
Comment on lines
+142
to
+144
| int current_total = max_money_without_last + num; | ||
| max_money_without_last = max(max_money_without_last, max_money_with_last); | ||
| max_money_with_last = current_total; |
5ky7
reviewed
Feb 26, 2026
| for (auto num : nums) { | ||
| int current_max = max(max_money_with_last, max_money_without_last + num); | ||
| max_money_without_last = max_money_with_last; | ||
| max_money_with_last = current_max; |
There was a problem hiding this comment.
with_lastだとlastに対応する要素を含むもので最大のもの,という誤認をしそうなのでby_lastやmax_money_previousなどはいかがでしょうか.
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.
今回の問題
https://leetcode.com/problems/house-robber/
次の問題
https://leetcode.com/problems/house-robber-ii/