Skip to content

Instantly share code, notes, and snippets.

@Peilonrayz
Created March 15, 2019 16:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Peilonrayz/7796a1e96818779693436bfb1de64f7f to your computer and use it in GitHub Desktop.
Save Peilonrayz/7796a1e96818779693436bfb1de64f7f to your computer and use it in GitHub Desktop.
def contiguous_sum(numbers, target):
end = 0
total = 0
for value in numbers:
total += value
if total == target:
return True
while total > target:
total -= numbers[end]
end += 1
return False
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment