Skip to content

Commit 31e8e10

Browse files
committed
Feb 13
1 parent 95a8ba9 commit 31e8e10

File tree

2 files changed

+29
-2
lines changed

2 files changed

+29
-2
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
from heapq import heapify, heappop, heappush
2+
3+
4+
class Solution:
5+
def minOperations(self, nums: list[int], k: int) -> int:
6+
heapify(nums)
7+
count = 0
8+
while nums[0] < k:
9+
x = heappop(nums)
10+
y = heappop(nums)
11+
heappush(nums, x*2 + y)
12+
count += 1
13+
return count
14+
15+
16+
def main():
17+
nums = [2, 11, 10, 1, 3]
18+
k = 10
19+
assert Solution().minOperations(nums, k) == 2
20+
21+
nums = [1, 1, 2, 4, 9]
22+
k = 20
23+
assert Solution().minOperations(nums, k) == 4
24+
25+
26+
if __name__ == '__main__':
27+
main()

2025-02-February-LeetCoding-Challenge/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
| February 10 | [3174. Clear Digits](https://leetcode.com/problems/clear-digits/) | Easy | Solved |
1717
| February 11 | [1910. Remove All Occurrences of a Substring](https://leetcode.com/problems/remove-all-occurrences-of-a-substring/) | Medium | Solved |
1818
| February 12 | [2342. Max Sum of a Pair With Equal Sum of Digits](https://leetcode.com/problems/max-sum-of-a-pair-with-equal-sum-of-digits/) | Medium | Solved |
19-
| February 13 | []() | | |
19+
| February 13 | [3066. Minimum Operations to Exceed Threshold Value II](https://leetcode.com/problems/minimum-operations-to-exceed-threshold-value-ii/) | Medium | Solved |
2020
| February 14 | []() | | |
2121
| February 15 | []() | | |
2222
| February 16 | []() | | |
@@ -38,5 +38,5 @@
3838
| Level | Problems | Solved | Unsolved |
3939
| --- | --- | --- | --- |
4040
| Easy | 6 | 6 | 0 |
41-
| Medium | 6 | 6 | 0 |
41+
| Medium | 7 | 7 | 0 |
4242
| Hard | 0 | 0 | 0 |

0 commit comments

Comments
 (0)