Saturday, September 1, 2018

Birthday Chocolate : Algorithms - Implementation

#The solution in Python3 is as follows:


def solve(n, a, d, m):
    count = 0
    for i in range(0,n):
          total = sum(a[i:m+i])
          if total == d:
                count+=1
         return count
n=int(input())
a=list(map(int,input().split()))
d,m=map(int,input().split())
print(solve(n,a,d,m))

#Keep visiting for more solutions of HackerRank problems in Python 3.Thank you!!!