← 返回 roblox 的题目列表Interval Counting
类型:online_judge
Given an integer array and a target value, find all intervals that use a combination of two-pointer, sliding window, or prefix sum techniques whose total sum equals the target value.
Input
An integer array nums, with size n.
An integer target.
Output
Count of intervals whose sum equals the target value.
Example
Input: nums = [1, 2, 3, 4, 5], target = 5
Output: 2
Explanation: The intervals [2, 3] and [5] meet the condition.
Constraints
1 <= n <= 10^5
-10^4 <= nums[i] <= 10^4
-10^9 <= target <= 10^9
Example
Input
5
1 2 3 4 5
5