2233. Maximum Product After K Increments

Updated: 2024-03-12
1 min read
[]

On This Page

LeetCode problem 2233

class Solution:
    def maximumProduct(self, nums: List[int], k: int) -> int:
        heapify(nums)
        for _ in range(k):
            heappush(nums, heappop(nums) + 1)
        res = 1
        mod = 10**9 + 7
        for v in nums:
            res = (res * v) % mod
        return res