You are viewing a single comment's thread. Return to all comments →
Here is Python 3 solution from my HackerrankPractice repository:
n, s = int(input().strip()), list(map(int, input().split()))
d, m = map(int, input().split())
print(sum([sum(s[i : i + m]) == d for i in range(len(s) - m + 1)]))
Feel free to ask if you have any questions :)
can you explain that please :-(
This is what i was looking for!
It's O(n*m), can be done faster with O(n).
One-liner doesn't make it good solution.