java.lang.Object
g2401_2500.s2439_minimize_maximum_of_array.Solution

public class Solution extends Object
2439 - Minimize Maximum of Array.<p>Medium</p> <p>You are given a <strong>0-indexed</strong> array <code>nums</code> comprising of <code>n</code> non-negative integers.</p> <p>In one operation, you must:</p> <ul> <li>Choose an integer <code>i</code> such that <code>1 <= i < n</code> and <code>nums[i] > 0</code>.</li> <li>Decrease <code>nums[i]</code> by 1.</li> <li>Increase <code>nums[i - 1]</code> by 1.</li> </ul> <p>Return <em>the <strong>minimum</strong> possible value of the <strong>maximum</strong> integer of</em> <code>nums</code> <em>after performing <strong>any</strong> number of operations</em>.</p> <p><strong>Example 1:</strong></p> <p><strong>Input:</strong> nums = [3,7,1,6]</p> <p><strong>Output:</strong> 5</p> <p><strong>Explanation:</strong> One set of optimal operations is as follows:</p> <ol> <li>Choose i = 1, and nums becomes [4,6,1,6].</li> <li>Choose i = 3, and nums becomes [4,6,2,5].</li> <li>Choose i = 1, and nums becomes [5,5,2,5].</li> </ol> <p>The maximum integer of nums is 5. It can be shown that the maximum number cannot be less than 5.</p> <p>Therefore, we return 5.</p> <p><strong>Example 2:</strong></p> <p><strong>Input:</strong> nums = [10,1]</p> <p><strong>Output:</strong> 10</p> <p><strong>Explanation:</strong> It is optimal to leave nums as is, and since 10 is the maximum value, we return 10.</p> <p><strong>Constraints:</strong></p> <ul> <li><code>n == nums.length</code></li> <li><code>2 <= n <= 10<sup>5</sup></code></li> <li><code>0 <= nums[i] <= 10<sup>9</sup></code></li> </ul>
  • Constructor Details

    • Solution

      public Solution()
  • Method Details

    • minimizeArrayValue

      public int minimizeArrayValue(int[] nums)