• + 2 comments

    why not O(n) like below

    def solve(n, s, d, m):
        if(n==1 and s[0]==d):
            return 1
        elif(n==1):
            return 0
        count = 0
        for i in range(len(s)-1):
            if(sum(s[i:m+i])==d):
                count = count + 1
        return count
        # Complete this function