summaryrefslogtreecommitdiff
path: root/progs/unparsable_programs/a424.py
blob: fb15cae5dfe8f837b81307c6c3fe368f8fa57467 (plain)
1
2
3
4
5
6
7
8
9
10
from collections import defaultdict
def count_Substrings(s,n):
    count,sum = 0,0
    mp = defaultdict(lambda : 0)
    mp[0] += 1
    for i in range(n):
        sum += ord(s[i]) - ord('0')
        count += mp[sum - (i + 1)]
        mp[sum - (i + 1)] += 1
    return count