File tree 7 files changed +257
-6
lines changed
7 files changed +257
-6
lines changed Original file line number Diff line number Diff line change 1
1
| 题目 | 题解 | 难度 | 推荐指数 |
2
2
| ------------------------------------------------------------ | ------------------------------------------------------------ | ---- | -------- |
3
+ | [ 239. 滑动窗口最大值] ( https://leetcode.cn/problems/sliding-window-maximum/ ) | [ LeetCode 题解链接] ( https://leetcode.cn/problems/sliding-window-maximum/solution/by-ac_oier-o89l/ ) | 困难 | 🤩🤩🤩🤩🤩 |
3
4
| [ 933. 最近的请求次数] ( https://leetcode-cn.com/problems/number-of-recent-calls/ ) | [ LeetCode 题解链接] ( https://leetcode-cn.com/problems/number-of-recent-calls/solution/by-ac_oier-evqe/ ) | 简单 | 🤩🤩🤩🤩🤩 |
4
5
| [ 729. 我的日程安排表 I] ( https://leetcode.cn/problems/my-calendar-i/ ) | [ LeetCode 题解链接] ( https://leetcode.cn/problems/my-calendar-i/solution/by-ac_oier-hnjl/ ) | 中等 | 🤩🤩🤩🤩 |
5
6
| [ 732. 我的日程安排表 III] ( https://leetcode-cn.com/problems/my-calendar-iii/ ) | [ LeetCode 题解链接] ( https://leetcode-cn.com/problems/my-calendar-iii/solution/by-ac_oier-cv31/ ) | 困难 | 🤩🤩🤩 |
7
+ | [ 剑指 Offer 59 - I. 滑动窗口的最大值] ( https://leetcode.cn/problems/hua-dong-chuang-kou-de-zui-da-zhi-lcof/ ) | [ LeetCode 题解链接] ( https://leetcode.cn/problems/hua-dong-chuang-kou-de-zui-da-zhi-lcof/solution/by-ac_oier-sjym/ ) | 困难 | 🤩🤩🤩🤩🤩 |
6
8
Original file line number Diff line number Diff line change 1
1
| 题目 | 题解 | 难度 | 推荐指数 |
2
2
| ------------------------------------------------------------ | ------------------------------------------------------------ | ---- | -------- |
3
+ | [ 239. 滑动窗口最大值] ( https://leetcode.cn/problems/sliding-window-maximum/ ) | [ LeetCode 题解链接] ( https://leetcode.cn/problems/sliding-window-maximum/solution/by-ac_oier-o89l/ ) | 困难 | 🤩🤩🤩🤩🤩 |
3
4
| [ 1438. 绝对差不超过限制的最长连续子数组] ( https://leetcode-cn.com/problems/longest-continuous-subarray-with-absolute-diff-less-than-or-equal-to-limit/ ) | [ LeetCode 题解链接] ( https://leetcode-cn.com/problems/longest-continuous-subarray-with-absolute-diff-less-than-or-equal-to-limit/solution/xiang-jie-er-fen-hua-dong-chuang-kou-dan-41g1/ ) | 中等 | 🤩🤩🤩 |
5
+ | [ 剑指 Offer 59 - I. 滑动窗口的最大值] ( https://leetcode.cn/problems/hua-dong-chuang-kou-de-zui-da-zhi-lcof/ ) | [ LeetCode 题解链接] ( https://leetcode.cn/problems/hua-dong-chuang-kou-de-zui-da-zhi-lcof/solution/by-ac_oier-sjym/ ) | 困难 | 🤩🤩🤩🤩🤩 |
4
6
Original file line number Diff line number Diff line change 2
2
| ------------------------------------------------------------ | ------------------------------------------------------------ | ---- | -------- |
3
3
| [ 23. 合并K个升序链表] ( https://leetcode-cn.com/problems/merge-k-sorted-lists/ ) | [ LeetCode 题解链接] ( https://leetcode-cn.com/problems/merge-k-sorted-lists/solution/shua-chuan-lc-you-xian-dui-lie-jie-fa-sh-3flb/ ) | 困难 | 🤩🤩🤩 |
4
4
| [ 218. 天际线问题] ( https://leetcode-cn.com/problems/the-skyline-problem/ ) | [ LeetCode 题解链接] ( https://leetcode-cn.com/problems/the-skyline-problem/solution/gong-shui-san-xie-sao-miao-xian-suan-fa-0z6xc/ ) | 困难 | 🤩🤩🤩 |
5
+ | [ 239. 滑动窗口最大值] ( https://leetcode.cn/problems/sliding-window-maximum/ ) | [ LeetCode 题解链接] ( https://leetcode.cn/problems/sliding-window-maximum/solution/by-ac_oier-o89l/ ) | 困难 | 🤩🤩🤩🤩🤩 |
5
6
| [ 264. 丑数 II] ( https://leetcode-cn.com/problems/ugly-number-ii/ ) | [ LeetCode 题解链接] ( https://leetcode-cn.com/problems/ugly-number-ii/solution/gong-shui-san-xie-yi-ti-shuang-jie-you-x-3nvs/ ) | 中等 | 🤩🤩🤩 |
6
7
| [ 295. 数据流的中位数] ( https://leetcode-cn.com/problems/find-median-from-data-stream/ ) | [ LeetCode 题解链接] ( https://leetcode-cn.com/problems/find-median-from-data-stream/solution/gong-shui-san-xie-jing-dian-shu-ju-jie-g-pqy8/ ) | 中等 | 🤩🤩🤩🤩 |
7
8
| [ 313. 超级丑数] ( https://leetcode-cn.com/problems/super-ugly-number/ ) | [ LeetCode 题解链接] ( https://leetcode-cn.com/problems/super-ugly-number/solution/gong-shui-san-xie-yi-ti-shuang-jie-you-x-jyow/ ) | 中等 | 🤩🤩🤩 |
26
27
| [ 1705. 吃苹果的最大数目] ( https://leetcode-cn.com/problems/maximum-number-of-eaten-apples/ ) | [ LeetCode 题解链接] ( https://leetcode-cn.com/problems/maximum-number-of-eaten-apples/solution/gong-shui-san-xie-noxiang-xin-ke-xue-xi-hfdy0/ ) | 中等 | 🤩🤩🤩🤩🤩 |
27
28
| [ 1834. 单线程 CPU] ( https://leetcode-cn.com/problems/single-threaded-cpu/ ) | [ LeetCode 题解链接] ( https://leetcode-cn.com/problems/single-threaded-cpu/solution/gong-shui-san-xie-shu-ju-jie-gou-yun-yon-1qk0/ ) | 中等 | 🤩🤩🤩🤩 |
28
29
| [ 剑指 Offer 41. 数据流中的中位数] ( https://leetcode.cn/problems/shu-ju-liu-zhong-de-zhong-wei-shu-lcof/ ) | [ LeetCode 题解链接] ( https://leetcode.cn/problems/shu-ju-liu-zhong-de-zhong-wei-shu-lcof/solution/by-ac_oier-exn5/ ) | 困难 | 🤩🤩🤩🤩🤩 |
30
+ | [ 剑指 Offer 59 - I. 滑动窗口的最大值] ( https://leetcode.cn/problems/hua-dong-chuang-kou-de-zui-da-zhi-lcof/ ) | [ LeetCode 题解链接] ( https://leetcode.cn/problems/hua-dong-chuang-kou-de-zui-da-zhi-lcof/solution/by-ac_oier-sjym/ ) | 困难 | 🤩🤩🤩🤩🤩 |
29
31
| [ 面试题 17.14. 最小K个数] ( https://leetcode-cn.com/problems/smallest-k-lcci/ ) | [ LeetCode 题解链接] ( https://leetcode-cn.com/problems/smallest-k-lcci/solution/gong-shui-san-xie-yi-ti-si-jie-you-xian-yy5k5/ ) | 中等 | 🤩🤩🤩🤩 |
30
32
Original file line number Diff line number Diff line change 1
1
| 题目 | 题解 | 难度 | 推荐指数 |
2
2
| ------------------------------------------------------------ | ------------------------------------------------------------ | ---- | -------- |
3
+ | [ 239. 滑动窗口最大值] ( https://leetcode.cn/problems/sliding-window-maximum/ ) | [ LeetCode 题解链接] ( https://leetcode.cn/problems/sliding-window-maximum/solution/by-ac_oier-o89l/ ) | 困难 | 🤩🤩🤩🤩🤩 |
3
4
| [ 307. 区域和检索 - 数组可修改] ( https://leetcode-cn.com/problems/range-sum-query-mutable/ ) | [ LeetCode 题解链接] ( https://leetcode-cn.com/problems/range-sum-query-mutable/solution/by-ac_oier-zmbn/ ) | 中等 | 🤩🤩🤩🤩🤩 |
4
5
| [ 327. 区间和的个数] ( https://leetcode.cn/problems/count-of-range-sum/ ) | [ LeetCode 题解链接] ( https://leetcode.cn/problems/count-of-range-sum/solution/by-ac_oier-b36o/ ) | 困难 | 🤩🤩🤩🤩🤩 |
5
6
| [ 654. 最大二叉树] ( https://leetcode.cn/problems/maximum-binary-tree/ ) | [ LeetCode 题解链接] ( https://leetcode.cn/problems/maximum-binary-tree/solution/by-ac_oier-s0wc/ ) | 中等 | 🤩🤩🤩🤩🤩 |
12
13
| [ 1109. 航班预订统计] ( https://leetcode-cn.com/problems/corporate-flight-bookings/ ) | [ LeetCode 题解链接] ( https://leetcode-cn.com/problems/corporate-flight-bookings/solution/gong-shui-san-xie-yi-ti-shuang-jie-chai-fm1ef/ ) | 中等 | 🤩🤩🤩🤩🤩 |
13
14
| [ 1893. 检查是否区域内所有整数都被覆盖] ( https://leetcode-cn.com/problems/check-if-all-the-integers-in-a-range-are-covered/ ) | [ LeetCode 题解链接] ( https://leetcode-cn.com/problems/check-if-all-the-integers-in-a-range-are-covered/solution/gong-shui-san-xie-yi-ti-shuang-jie-mo-ni-j83x/ ) | 简单 | 🤩🤩🤩🤩 |
14
15
| [ 2213. 由单个字符重复的最长子字符串] ( https://leetcode-cn.com/problems/longest-substring-of-one-repeating-character/ ) | [ LeetCode 题解链接] ( https://leetcode-cn.com/problems/longest-substring-of-one-repeating-character/solution/by-ac_oier-0lso/ ) | 困难 | 🤩🤩🤩🤩🤩 |
16
+ | [ 剑指 Offer 59 - I. 滑动窗口的最大值] ( https://leetcode.cn/problems/hua-dong-chuang-kou-de-zui-da-zhi-lcof/ ) | [ LeetCode 题解链接] ( https://leetcode.cn/problems/hua-dong-chuang-kou-de-zui-da-zhi-lcof/solution/by-ac_oier-sjym/ ) | 困难 | 🤩🤩🤩🤩🤩 |
15
17
Original file line number Diff line number Diff line change 1
1
### 题目描述
2
2
3
- 这是 LeetCode 上的 ** [ 239. 滑动窗口最大值] ( ) ** ,难度为 ** 困难** 。
3
+ 这是 LeetCode 上的 ** [ 239. 滑动窗口最大值] ( https://leetcode.cn/problems/sliding-window-maximum/solution/by-ac_oier-o89l/ ) ** ,难度为 ** 困难** 。
4
4
5
5
Tag : 「优先队列(堆)」、「线段树」、「分块」、「单调队列」、「RMQ」
6
6
Original file line number Diff line number Diff line change @@ -42,15 +42,15 @@ Tag : 「数学」、「二分」、「容斥原理」
42
42
43
43
### 数学 + 二分
44
44
45
- 对于一个 $n! = 1 \times 2 \times ... \times (n - 1) \times n$ 而言,其最终结果尾部包含 $0$ 的数量取决于其被累乘 $10$ 的次数,而 $10$ 可通过质因数 $2$ 和 $5$ 相乘而来,因此假设对 $n!$ 中的每一数进行阶乘分解 ,最终分解出 $2^p$ 和 $5^q$ 的话,那么最终结果尾部包含 $0$ 的个数为 $q$ 个(可证明 $p < = q$ 始终满足)。
45
+ 对于一个 $n! = 1 \times 2 \times ... \times (n - 1) \times n$ 而言,其最终结果尾部包含 $0$ 的数量取决于其被累乘 $10$ 的次数,而 $10$ 可通过质因数 $2$ 和 $5$ 相乘而来,因此假设对 $n!$ 进行阶乘分解 ,最终分解出 $2^p$ 和 $5^q$ 的话,那么最终结果尾部包含 $0$ 的个数为 $q$ 个(可证明 $p > = q$ 始终满足)。
46
46
47
- 因此原问题转化为:在非负整数中,有多少个数进行阶乘分解后,所含质因数 $5$ 的个数为 $k$ 个。
47
+ 因此原问题转化为:在非负整数中,有多少个数进行阶乘分解后,所含质因数 $5$ 的个数恰好为 $k$ 个。
48
48
49
49
同时我们可知:随着 $n$ 的增大,其所能分解出来的 $5$ 的个数必然是递增的。
50
50
51
- 基于此,我们可以通过「二分 + 容斥原理」来得出分解 $5$ 个数恰好为 $k$ 的连续段长度。假设我们存在函数 ` f(k) ` 可得到非负整数中分解 $5$ 个数为小于等于 ` k ` 的个数,那么最终 ` f(k) - f(k - 1) ` 即答案 。
51
+ 基于此,我们可以通过「二分 + 容斥原理」来得出分解 $5$ 个数恰好为 $k$ 的连续段长度。假设我们存在函数 ` f(k) ` 可得到非负整数中分解 $5$ 个数为小于等于 ` k ` 的个数,那么最终 ` f(k) - f(k - 1) ` 即是答案 。
52
52
53
- 在单调函数上求解小于等于 ` k ` 分割点,可通过「二分」来做, 剩下的问题是,如何求得给定 ` x ` 时,其阶乘分解所包含 $5$ 个个数,这可以通过 $O(\log{x})$ 的筛法来做。
53
+ 在单调函数上求解小于等于 ` k ` 分割点,可通过「二分」来做。 剩下的问题是,如何求得给定 ` x ` 时,其阶乘分解所包含 $5$ 个个数,这可以通过 $O(\log{x})$ 的筛法来做。
54
54
55
55
最后还要确定二分的值域,由于我们是求阶乘分解中 $5$ 的个数,因此值域的上界为 $5k$,利用 $k$ 的范围为 $1e9$,直接取成 $1e10$ 即可。
56
56
@@ -102,7 +102,7 @@ function getCnt(x: bigint): bigint {
102
102
return ans
103
103
}
104
104
```
105
- * 时间复杂度:$O(\log{k})$
105
+ * 时间复杂度:$O(\log^2 {k})$
106
106
* 空间复杂度:$O(1)$
107
107
108
108
---
You can’t perform that action at this time.
0 commit comments