Company: ibm_29sep
Difficulty: medium
Minimum Operations to Zero Array Problem Description Implement a function that determines the number of operations required to reduce all elements of a given array arr to zero. In each operation, traverse the whole array from left to right. For each index i (from 0 to n-1 ), using 0 -based indexing: If arr[i] > arr[i-1] and i > 0 , update arr[i] to max(0, arr[i] - 1) . Otherwise, leave arr[i] unchanged. The function getNumberOfOperations will take one input: int arr[] the given array of positive integers. The function signature is as follows: int getNumberOfOperations(vector<int> arr) The function should return an integer denoting the number of operations required to make all elements of arr equal to zero. Examples Example 1: Input: n = 3, arr = [1,3,1] Explanation: Here, the underlined elements represent those changed during the operation and their modified values. The sequence of operations: Operation Number | arr before | arr after -----------------|------------|--------