Maximum Product After K Increments LeetCode solution in Python

1
class Solution:
2
def maximumProduct(self, nums: List[int], k: int) -> int:
3
heap = nums.copy()
4
heapify(heap)
5
for i in range(k):
6
t = heappop(heap)
7
heappush(heap, t + 1)
8
ans = 1
9
mod = 1000000007
10
for i in heap:
11
ans = (ans * i) % mod
12
return ans

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0