Solving a simple HackerRank problem called:Sub-array Division using python.

Problem

Given a chocolate bar, two children, Lily and Ron, are determining how to share it. Each of the squares has an integer on it.

Lily decides to share a contiguous segment of the bar selected such that:

  • The length of the segment matches Ron's birth month, and,
  • The sum of the integers on the squares is equal to his birth day.

You must determine how many ways she can divide the chocolate.

See the full description of the problem here : Sub-array Division

Sample Input

5
1 2 1 3 2
3 2

Sample Input

2

let me know in the comment bellow if you got any better way to solve this.