You're an investment manager with a portfolio of non-negative integer assets and exactly k investment opportunities. Each opportunity allows you to increase any single asset's value by 1.
Your goal is to maximize the total product of all asset values after making at most k investments. Since the final product could be astronomically large, return it modulo 109 + 7.
Key insight: To maximize a product, you should always invest in the smallest current asset first, as this gives the highest relative return on investment.
Example: With assets [0, 4] and k = 5 investments:
• Invest 1 in asset 0: [1, 4] (product = 4)
• Invest 1 in asset 0: [2, 4] (product = 8)
• Invest 1 in asset 0: [3, 4] (product = 12)
• Invest 1 in asset 0: [4, 4] (product = 16)
• Invest 1 in either: [5, 4] or [4, 5] (product = 20)
Input & Output
Constraints
- 1 ≤ nums.length ≤ 105
- 0 ≤ nums[i] ≤ 106
- 1 ≤ k ≤ 105
- Return result modulo 109 + 7