499. Maximize the Minimum After K Increments

MediumBinary SearchBinary Search on AnswerGreedy

Given an array and k operations where each operation increases any single element by 1, maximize the minimum element of the array after applying at most k operations. Return that maximum possible minimum value. Input: '[arr], k'.

Input: '[arr], k'.

Output: Integer — the maximized minimum value.

Examples

Example 1
Input: [1,2,3,4], 3
Output: 3
Explanation: Raise the small elements; min becomes 3.
Example 2
Input: [5,5,5], 0
Output: 5
Explanation: No operations; min stays 5.
Example 3
Input: [1], 10
Output: 11
Explanation: Single element raised by 10.

Constraints

Asked by

AmazonMicrosoftGoogleAdobeFlipkart
Solve this problem in the editor →