Company: EPAM
Difficulty: medium
In this problem, you are given an array arr of integers. Your task is to find the number of contiguous subarrays that sum up to zero. A subarray is a contiguous part of the array, and the sum of its elements should be equal to zero. Input Format The first line contains an integer n representing the length of the array. The second line contains n space-separated integers representing the elements of the array. Output Format Output a single integer: the number of subarrays whose sum is zero. Constraints 1 ≤ n ≤ 10 5 -10 5 ≤ arr[i] ≤ 10 5 Execution time limit: 4 seconds Example 1 Input 6 1 -3 2 3 6 4 Output 1 Explanation: the array has one subarray [1, -3, 2] that sums to zero. Example 2 Input 8 4 8 9 -4 1 -1 -8 -9 Output 2 Explanation: only two subarrays sum to zero: [1, -1] (indices 4 to 5) the entire array [4, 8, 9, -4, 1, -1, -8, -9] (indices 0 to 7)