A tea stall writes down its profit or loss for each day in the list nums. A loss is a negative number.
Count the stretches of days, one day after another with no gap, whose total is exactly k. A stretch must have at least one day. Two stretches are different if they start or end on different days, even when their numbers look the same.
Return how many such stretches there are.
Examples
Example 1:
Input: nums = [2,2,2,2], k = 4
Output: 3
Explanation: The stretch [2,2] adds up to 4. It can be taken in three places: days 0-1, days 1-2 and days 2-3.
Example 2:
Input: nums = [1,-1,1,-1], k = 0
Output: 4
Explanation: The stretches with total 0 are [1,-1] (twice), [-1,1], and the whole list.
Example 3:
Input: nums = [5], k = 3
Output: 0
Explanation: The only stretch is [5], and 5 is not 3.