File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11# [ 3296. 移山所需的最少秒数] ( https://leetcode.cn/problems/minimum-number-of-seconds-to-make-mountain-height-zero/description/ )
22
3- > ** 作者 ** :弘树
4- > ** 日期 ** :2024-09-22
3+ > ** 日期 ** :2024-09-22、2026-03-13
4+ > ** 知识点 ** :二分答案
55
66## 1. 二分答案
77
3232- 时间复杂度: $O(nlogU)$
3333- 空间复杂度: $O(1)$
3434
35+ ** Python3**
36+
37+ ``` python
38+ class Solution :
39+ def minNumberOfSeconds (self , mountainHeight : int , workerTimes : List[int ]) -> int :
40+ def check (minute ):
41+ height = 0
42+ for workerTime in workerTimes:
43+ h = int (sqrt(minute * 2 / workerTime))
44+ while h * (h + 1 ) * workerTime > 2 * minute:
45+ h -= 1
46+ height += h
47+ if height >= mountainHeight:
48+ return True
49+ return False
50+
51+ l, r = 1 , int (1e17 )
52+ while l < r:
53+ mid = l + r >> 1
54+ if check(mid):
55+ r = mid
56+ else :
57+ l = mid + 1
58+ return r
59+ ```
60+
3561** C++**
3662
3763``` C++
Original file line number Diff line number Diff line change 11# [ 2826. 将三个组排序] ( https://leetcode.cn/problems/sorting-three-groups/description/ )
22
3- > ** 日期** :2025-05-22
3+ > ** 日期** :2025-05-22、2026-03-13
44> ** 所用时间** :2min
55
66## 1. 最长递增子序列
@@ -30,4 +30,19 @@ class Solution:
3030 if nums[i] >= nums[j]:
3131 f[i] = max (f[i], f[j] + 1 )
3232 return len (nums) - max (f)
33+ ```
34+
35+ ** Python3**
36+
37+ ``` python
38+ class Solution :
39+ def minimumOperations (self , nums : List[int ]) -> int :
40+ f = []
41+ for x in nums:
42+ i = bisect.bisect_right(f, x)
43+ if i == len (f):
44+ f.append(x)
45+ else :
46+ f[i] = x
47+ return len (nums) - len (f)
3348```
You can’t perform that action at this time.
0 commit comments