2845. Count-Of-Interesting-Subarrays

Question Link

Difficulty: Medium

yea lowkey did not know what this was

class Solution(object):
    def countInterestingSubarrays(self, nums, modulo, k):
        """
        :type nums: List[int]
        :type modulo: int
        :type k: int
        :rtype: int
        """
        n = len(nums)
        count = Counter([0])
        res = 0
        prefix = 0
        for i in range(n):
            prefix += 1 if nums[i] % modulo == k else 0
            res += count[(prefix - k + modulo) % modulo]
            count[prefix % modulo] += 1
        return res

Time Complexity: O(n)

Space Complexity: O(min(n, modulo))

Time Taken: did not complete