Subarray Division

mail@pastecode.io avatar
unknown
python
2 years ago
410 B
5
Indexable
Never
def birthday(s, d, m):
    # Write your code here
    count_of_square = 0

    # loop for length of array time
    for i in range(len(s)-1):
        # if i is second last and addition is d then only increment the counter
        if i < (len(s)-2) and s[i]+s[i+1] == d:
            count_of_square += 1

    return count_of_square


s = [1, 2, 1, 3, 2]
d = 3
m = 2

print(birthday(s, d, m))