TeachMint may need to analyze contiguous activity windows in a learner's engagement sequence. Given an integer array nums and an integer k, return the number of contiguous subarrays whose elements sum exactly to k.
Values may be positive, zero, or negative, so solutions must not rely on a sliding-window assumption.
Implement count_subarrays(nums, k).
nums, a list of integers, and k, an integer target sum.k.def count_subarrays(nums, k):