Company: oracle_31july
Difficulty: medium
Maximize Array Value Problem Description Given an array of n positive integers with 1-based indexing, you can perform the following operation any number of times: Choose any index i where 2 ≤ i ≤ n Choose any value x where 1 ≤ x ≤ arr[i] Set arr[i-1] to arr[i-1] + x Set arr[i] to arr[i] - x Your task is to minimize the maximum value in the array and return this minimum possible maximum. Examples Example 1: Input: n = 4, arr = [1, 5, 7, 6] Output: 5 Explanation: Optimal sequence of operations: Operation 1: Choose i = 3, x = 4 Replace arr[2] with 5+4 = 9 Replace arr[3] with 7-4 = 3 Array becomes [1, 9, 3, 6] with maximum 9 Operation 2: Choose i = 2, x = 4 Replace arr[1] with 1+4 = 5 Replace arr[2] with 9-4 = 5 Array becomes [5, 5, 3, 6] with maximum 6 Operation 3: Choose i = 4, x = 1 Replace arr[3] with 3+1 = 4 Replace arr[4] with 6-1 = 5 Array becomes [5, 5, 4, 5] with maximum 5 The minimum possible maximum value is 5. Sample Case 0: Input: n = 3, arr = [5, 15, 19] Output: 1