':type nums: List[int]
:type k: int
:rtype: int'

def subarraySum(self, nums, k):

    result = 0
    accumulated_sum = 0
    lookup = collections.defaultdict(int)
    lookup[0] += 1
    for num in nums:
        accumulated_sum += num
        result += lookup[(accumulated_sum - k)]
        lookup[accumulated_sum] += 1
    return result
