Maximum Product After K Increments
You are given an array of non-negative integers nums and an integer k. In one operation, you may choose any element from nums and increment it by 1.
Return the maximum product of nums after at most k operations. Since the answer may be very large, return it modulo 10^9 + 7. Note that you should maximize the product before taking the modulo.
Example 1
Input
nums = [0,4], k = 5Output
20Incrementing the first number 5 times gives
nums = [5, 4], whose product is 20, the maximum possible product.Example 2
Input
nums = [6,3,3,2], k = 2Output
216Incrementing the second number once and the fourth number once gives
nums = [6, 4, 3, 3], whose product is 216, the maximum possible product.Constraints
- 1 <= nums.length, k <= 10^5
- 0 <= nums[i] <= 10^6