Practice Minimum Operations to Exceed Threshold Value II
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Medium#3066
LeetCode ProblemMinimum Operations to Exceed Threshold Value II
Problem Statement
Given nums and k, one operation removes the two smallest values x and y and inserts 2 * min(x, y) + max(x, y). An operation requires at least two elements. Return the minimum number of operations until every remaining value is at least k.
Source: Minimum Operations to Exceed Threshold Value II on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
Input
nums = [2,11,10,1,3], k = 10
Output
2
# Example 2
Input
nums = [1,1,2,4,9], k = 20
Output
4
Constraints
2 <= nums.length <= 2 * 10^5
1 <= nums[i] <= 10^9
1 <= k <= 10^9
The input is generated such that an answer always exists. That is, after performing some number of operations, all elements of the array are greater than or equal to k.
Related LeetCode Problems
Practice more problems similar to Minimum Operations to Exceed Threshold Value II.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.