Subarray Division 1

  • + 0 comments

    logic on python

    def testResult(result,d):
        count = 0
        for xy in result:
            temp = 0
            for record in xy:
                temp+=record
            if temp == d:
                count +=1
        return count
    def pushMRecord(idx, m, s):
        res = []
        for idxs in range(m):
            if idx + idxs < len(s): 
                res.append(s[idx + idxs])
        return res
    
    def birthday(s, d, m):
        # Write your code here
        temp = []
        result = []
        print(len(s),"sds")
        print(d,"sdac")
        if len(s) == d:
            return 1 
        for idx in range(len(s)):
            if idx == len(s)-m+1:
                continue
            temp = pushMRecord(idx, m, s)
            print("Tem", temp)
            if len(temp)==m:
                result.append(temp)
                temp = []
        print(result)
        testRes = testResult(result, d)
        return testRes