Skip to content

Latest commit

 

History

History
43 lines (29 loc) · 1.02 KB

_3066. Minimum Operations to Exceed Threshold Value II.md

File metadata and controls

43 lines (29 loc) · 1.02 KB

All prompts are owned by LeetCode. To view the prompt, click the title link above.

Back to top


First completed : February 13, 2025

Last updated : February 13, 2025


Related Topics : Array, Heap (Priority Queue), Simulation

Acceptance Rate : 45.74 %


Solutions

Python

class Solution:
    def minOperations(self, nums: List[int], k: int) -> int:
        heapq.heapify(nums)
        ops = 0

        while len(nums) >= 2 :
            a, b = heappop(nums), heappop(nums)

            if a >= k and b >= k :
                return ops
            heappush(nums, max(a, b) + 2 * min(a, b))
            ops += 1

        return ops