Skip to content

Instantly share code, notes, and snippets.

@hansrajdas
Created October 27, 2018 19:12
Show Gist options
  • Save hansrajdas/cc4a704e1b49e74a2087ae1cf3277e7b to your computer and use it in GitHub Desktop.
Save hansrajdas/cc4a704e1b49e74a2087ae1cf3277e7b to your computer and use it in GitHub Desktop.
# Complete the countSubSequence function below.
def countSubSequence(inputSeq, targetSum):
size = len(inputSeq)
count = 0
for i in range(0, size):
for j in range(i + 1, size + 1):
subSeq = inputSeq[i:j]
if sum(subSeq) == targetSum:
count += 1
return count
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment