Given an array of integers nums and an integer k, return the total number of subarrays whose sum equals k.
With nums = [1, 1, 1] and k = 2, the answer is 2. The subarrays [1, 1] starting at index 0 and starting at index 1 both sum to 2.
Note: subarrays must be contiguous. This isn't about subsets. How can prefix sums help you count these efficiently?
Constraints: , values from to .