<jupyter_start><jupyter_text>ProblemGiven an array of integers and an integer k, you need to find the total number of continuous subarrays whose sum equals to k.Example 1:```Input:nums = [1,1,1], k = 2Output: 2```Note:- The length of the array is in range [1, 20,000].- The range of numbers in the array is [-1000, 1000] and the range of the integer k is [-1e7, 1e7].  Solution<jupyter_code>def subarray_sum(nums: list, k: int) -> int:
    sums = {}
    current_sum = 0
    subarray_count = 0

    for num in nums:
        current_sum += num
        if current_sum == k:
            subarray_count += 1
        if (current_sum - k) in sums:
            subarray_count += sums[current_sum - k]
        sums.setdefault(current_sum, 0)
        sums[current_sum] += 1
    
    return subarray_count

subarray_sum([1,1,1], 1)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.10588235294117647, 'fraction_numerical': 0.03882352941176471, 'mean_word_length': 2.9766355140186915, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '371001', 'license': 'MIT', 'n_tokens_mistral': 315, 'n_tokens_neox': 283, 'n_words': 97, 'path': 'Day_22_Subarray_Sums_Equal_K.ipynb', 'repo_name': 'bundickm/LeetCode-30-Day-Challenge', 'size': '850'}