Add solutions
This commit is contained in:
commit
ed40cc2fd1
7
python/minimum_operations_to_exceed_threshold_value_i.py
Normal file
7
python/minimum_operations_to_exceed_threshold_value_i.py
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
class Solution:
|
||||||
|
def minOperations(self, nums: List[int], k: int) -> int:
|
||||||
|
heapify(nums)
|
||||||
|
operations = 0
|
||||||
|
while heappop(nums) < k:
|
||||||
|
operations += 1
|
||||||
|
return operations
|
@ -0,0 +1,9 @@
|
|||||||
|
class Solution:
|
||||||
|
def minOperations(self, nums: List[int], k: int) -> int:
|
||||||
|
heapify(nums)
|
||||||
|
operations = 0
|
||||||
|
while (x := heappop(nums)) < k:
|
||||||
|
y = heappop(nums)
|
||||||
|
heappush(nums, min(x,y)*2 + max(x,y))
|
||||||
|
operations += 1
|
||||||
|
return operations
|
Loading…
Reference in New Issue
Block a user