commit ed40cc2fd12d61a2df544142d413d384eef6172f Author: Kiril Kovachev Date: Fri Mar 8 16:42:50 2024 +0000 Add solutions diff --git a/python/minimum_operations_to_exceed_threshold_value_i.py b/python/minimum_operations_to_exceed_threshold_value_i.py new file mode 100644 index 0000000..546234f --- /dev/null +++ b/python/minimum_operations_to_exceed_threshold_value_i.py @@ -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 \ No newline at end of file diff --git a/python/minimum_operations_to_exceed_threshold_value_ii.py b/python/minimum_operations_to_exceed_threshold_value_ii.py new file mode 100644 index 0000000..c207153 --- /dev/null +++ b/python/minimum_operations_to_exceed_threshold_value_ii.py @@ -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 \ No newline at end of file