Maximum Product After K Increments LeetCode solution in Java
1class Solution {2public int maximumProduct(int[] nums, int k) {34Queue<Integer> pq = new PriorityQueue<>();5for (int num : nums) pq.add(num);67while (k-- > 0) {8int top = pq.poll() + 1;9pq.add(top);10}1112long res = 1;13while (!pq.isEmpty()) {14res = (res * pq.poll()) % 1000000007;15}1617return (int) (res);18}19}