Created
January 18, 2020 02:09
-
-
Save inspirit941/d4730e8974d3237d6a7c549817a3221c to your computer and use it in GitHub Desktop.
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
| def solution(money): | |
| table = [0 for _ in range(len(money))] | |
| # 첫 번째 집을 털 경우 | |
| table[0] = money[0] | |
| table[1] = table[0] | |
| for i in range(2, len(money) - 1): | |
| table[i] = max(table[i-1], table[i-2] + money[i]) | |
| value = max(table) | |
| # 첫 번째 집을 털지 않을 경우 | |
| table = [0 for _ in range(len(money))] | |
| table[1] = money[1] | |
| for i in range(2, len(money)): | |
| table[i] = max(table[i-1], table[i-2] + money[i]) | |
| return max(value, max(table)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment