Last active
January 12, 2018 00:12
-
-
Save jeffchiucp/6dbd481ce4bc208e6da68bc8e920bf3f to your computer and use it in GitHub Desktop.
robbery.py
This file contains 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 robbery(amounts): | |
amounts = iter(amounts) | |
prev, total = 0, next(amounts, 0) | |
for x in amounts: prev, total = total, max(total, prev + x) | |
return total |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment