Company: Publicis Sapient_22oct
Difficulty: medium
Count Balancing Elements Problem Description When an element is deleted from an array, higher-indexed elements shift down to fill the gap. A "balancing element" is one that, when deleted, results in the sum of even-indexed elements equaling the sum of odd-indexed elements in the resulting array. Your task is to determine how many balancing elements exist in a given array. Example: `arr = [5, 5, 2, 5, 8]` When the first 5 is deleted, the array becomes `[5, 2, 5, 8]`: Sum of even-indexed elements: 5 + 5 = 10 Sum of odd-indexed elements: 2 + 8 = 10 Similarly, when the second 5 is deleted, the array becomes `[5, 2, 5, 8]` with the same balanced sums. No other elements have this property, so there are 2 balancing elements: `arr[0]` and `arr[1]`. Complete the function `countBalancingElements` in the editor with the following parameter(s): `int arr[n]`: an array of integers Returns: `int`: the number of balancing elements in the input array The function signature is: int countBalancingElement