Your question is Array Sum by Value. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
The City of Providence processes ordered event values such as permit adjustments or service-request time changes. Given an integer array and a target value, analyze every non-empty contiguous subarray whose elements sum exactly to the target.
Implement a function that returns the number of matching subarrays, the shortest matching length, and the longest matching length. Array values may be negative, zero, or positive, so a sliding-window approach is not valid.
Implement analyze_target_subarrays(nums, target).
nums, a non-empty array of integers, and target, an integer.count: number of contiguous subarrays with sum equal to target.shortest: minimum length among matching subarrays, or 0 if none exist.longest: maximum length among matching subarrays, or 0 if none exist.def analyze_target_subarrays(nums, target):