#3066
Minimum Operations to Exceed Threshold Value II
specialist · 940 · lc medium +32 · 45.8% accepted · 632 likes · top 29%
Description
Given a 0-indexed integer array nums and an integer k, you may repeatedly perform the following operation while nums has at least two elements:
- Take the two smallest values x and y from nums and remove them.
- Insert the value (min(x, y) * 2 + max(x, y)) anywhere in the array.
Return the minimum number of operations until every element is at least k.
Code
1
2
3