Skip to content

Conversation

@fhiyo
Copy link
Owner

@fhiyo fhiyo commented Jul 7, 2024

Copy link

@hayashi-ay hayashi-ay left a comment

Choose a reason for hiding this comment

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

House Robberの方でしたコメント以外は特にないかなと思います

Comment on lines +110 to +112
prev = max_money_so_far[1]
max_money_so_far[1] = max(max_money_so_far[1], max_money_so_far[0] + nums[i])
max_money_so_far[0] = prev

Choose a reason for hiding this comment

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

好みかもしれませんが、こうした方が要素をずらしていることが分かりやすいと思いました。

current = max(max_money_so_far[1], max_money_so_far[0] + nums[i])
max_money_so_far[0] = max_money_so_far[1]
max_money_so_far[1] = current

Comment on lines +103 to +104
if len(nums) == 1:
return nums[0]

Choose a reason for hiding this comment

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

どのケースが該当するか少し混乱しました。
rob関数内でlen(nums) == 2のケースで処理しちゃってもいいと思いました。

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.

4 participants