You are viewing a single comment's thread. Return to all comments →
fun minSum(nums: Array<Int>, k: Int): Int { val maxHeap = PriorityQueue<Int>(reverseOrder()) maxHeap.addAll(nums.toList()) repeat(k) { val maxElement = maxHeap.poll() val newElement = Math.ceil(maxElement.toDouble() / 2).toInt() maxHeap.offer(newElement) } return maxHeap.sum() }
Seems like cookies are disabled on this browser, please enable them to open this website
Minimum Sum 10
You are viewing a single comment's thread. Return to all comments →