Input: arr[] = {1, 2, 3, 4, 5}, K = 2
Output: 9
Explanation:
At first B[] = {0, 0, 0, 0, 0} operations = 0
Increment subarray a[1:2] by 1 => B = {1, 1, 0, 0, 0}, operations = 1
Increment subarray a[2:3] by 1 => B = {1, 2, 1, 0, 0}, operations = 2
Increment subarray a[3:4] by 2 => B = {1, 2, 3, 2, 0}, operations = 4
Increment subarray a[4:5] by 5 => B = {1, 2, 3, 7, 5}, operations = 9
Therefore, count of such operations required is 9.
Input: arr[] = {2, 3, 1}, K = 3
Output: 3
Explanation:
Incrementing the entire array by 3