LearnPy Hub
← Dictionaries problems
Hard

Runs That Add Up to k

Read integers and k. Count the runs of one or more neighbouring numbers whose sum is exactly k. Keep a dictionary counting how often each running total has appeared so far.

Input

Integers, then k.

Output

One integer.

Sample 1

Input
1 1 1
2
Output
2

Sample 2

Input
1 2 3
3
Output
2
solution.py
Output appears here
Runs That Add Up to k · Python practice problem · LearnPy Hub