Skip to content

213. House Robber II#34

Open
tom4649 wants to merge 2 commits intomainfrom
213.House-Robber-II
Open

213. House Robber II#34
tom4649 wants to merge 2 commits intomainfrom
213.House-Robber-II

Conversation

@tom4649
Copy link
Copy Markdown
Owner

@tom4649 tom4649 commented Mar 28, 2026

max_with_last = max(max_with_last, max_without_last + money)
return max_with_last, next_max_without_last

return max(functools.reduce(visit_next, sequence, (0, 0)))
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

(0, 0) を初期値とする state の正体を読み解くのと、それが引き回されていく様子をイメージするのに手こずりました。sequence も命名の抽象度が上がり分かりにくく感じました。いずれもタイプヒントを書くと多少は助けになるかもしれません。

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.

なるほど、採用しました。型ヒントは可読性が向上しますね。

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.

2 participants