← 返回 bytedance 的题目列表Prefix Sum and Binary Search Problem
类型:online_judge
Given an array of integers, find the number of subarrays whose sum equals to the target value using prefix sum and binary search.
Input:
An array arr with n integers, which may contain negative numbers (1 <= n <= 10000, each element is in the range [-1000, 1000]).
An integer target, representing the target sum.
Output:
The number of subarrays satisfying the conditions.
Example:
Input: arr = [1, -1, 0], target = 0
Output: 3
Example
Input
3
1 -1 0
0