Created
September 6, 2020 13:22
-
-
Save Sadamingh/c984f8af62a5175505b40f3c869e0136 to your computer and use it in GitHub Desktop.
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 constrained_sum(nums: List[int]) -> int: | |
current, previous = 0, 0 | |
for value in nums: | |
previous, current = current, max(current, previous + value) | |
return current |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment