Your question is Subarray Sum Equals Target. 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.
Coforge analytics pipelines may need to detect whether a contiguous sequence of transaction adjustments reaches a required target. Given an integer array and a target value, determine whether at least one non-empty contiguous subarray has a sum exactly equal to the target.
Your solution must support positive numbers, zero, and negative numbers. Design it to run in expected O(n) time, since the input may contain up to one million values.
Implement has_subarray_sum(nums, target).
nums, a list of integers, and target, an integer.True if a non-empty contiguous subarray sums to target; otherwise, return False.def has_subarray_sum(nums, target):