Created
January 6, 2021 04:42
-
-
Save nma/35bbc3cdece428c4ff29089a10fbf8bf 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 rob_houses_dp_no_arr(house: List[int]) -> int: | |
if len(house) == 0: return 0 | |
if len(house) == 1: return house[0] | |
max_so_far = house[0] | |
max_2_houses_ago = 0 | |
for i in len(1, len(house)): | |
new_max = max(max_so_far, house[i] + max_2_houses_ago) | |
max_2_houses_ago = max_so_far | |
max_so_far = new_max | |
return max_so_far |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment