From 362565d8d2b4052e27236102053f7bf224e2d080 Mon Sep 17 00:00:00 2001 From: ITCharge Date: Wed, 10 Aug 2022 11:17:41 +0800 Subject: [PATCH 1/2] =?UTF-8?q?Update=200887.=20=E9=B8=A1=E8=9B=8B?= =?UTF-8?q?=E6=8E=89=E8=90=BD.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...41\350\233\213\346\216\211\350\220\275.md" | 63 ++++++++++++++----- 1 file changed, 49 insertions(+), 14 deletions(-) diff --git "a/Solutions/0887. \351\270\241\350\233\213\346\216\211\350\220\275.md" "b/Solutions/0887. \351\270\241\350\233\213\346\216\211\350\220\275.md" index 9937a9ef..c9d07bd7 100644 --- "a/Solutions/0887. \351\270\241\350\233\213\346\216\211\350\220\275.md" +++ "b/Solutions/0887. \351\270\241\350\233\213\346\216\211\350\220\275.md" @@ -28,9 +28,7 @@ ## 解题思路 -### 思路 1:动态规划(超时) - -这道题目的题意不是很容易理解,我们先把题目简化一下,忽略一些限制条件,理解简单情况下的题意。然后再一步步增加限制条件,从而先弄明白这道题目的意思。 +这道题目的题意不是很容易理解,我们先把题目简化一下,忽略一些限制条件,理解简单情况下的题意。然后再一步步增加限制条件,从而弄明白这道题目的意思。以及思考解题思路。 我们先忽略 `k` 个鸡蛋这个条件,假设有无限个鸡蛋。 @@ -43,7 +41,7 @@ - 如果鸡蛋没摔碎,则可以继续选择其他楼层进行测试。 - 如果鸡蛋摔碎了,则该鸡蛋无法继续测试。 -现在题目要求:一共有 `n` 层楼,无限个鸡蛋,求出至少需要扔几次鸡蛋,才能保证无论 `f` 是多少层,都能将 `f` 找出来? +现在题目要求:**已知有 `n` 层楼,无限个鸡蛋,求出至少需要扔几次鸡蛋,才能保证无论 `f` 是多少层,都能将 `f` 找出来?** 最简单且直观的想法: @@ -61,7 +59,7 @@ - 如果鸡蛋碎了,则从第 `1` 层到中间层这个区间中去扔鸡蛋。 - 如果鸡蛋没碎,则从中间层到第 `n` 层这个区间中去扔鸡蛋。 -每次扔鸡蛋都从区间的中间层去扔,这样每次都能排除当前区间一半的答案,从而最终确定鸡蛋不会摔碎的最高楼层 `f`。。 +每次扔鸡蛋都从区间的中间层去扔,这样每次都能排除当前区间一半的答案,从而最终确定鸡蛋不会摔碎的最高楼层 `f`。 通过这种二分查找的方法,可以优化到 $\log n$ 次就能确定鸡蛋不贵摔碎的最高楼层 `f`。 @@ -71,11 +69,13 @@ 这是不限制鸡蛋个数的情况下,现在在给定 `n` 层楼的基础上,再限制一下鸡蛋个数为 `k`。 -现在题目要求:一共有 `n` 层楼,`k` 个鸡蛋,求出至少需要扔几次鸡蛋,才能保证无论 `f` 是多少层,都能将 `f` 找出来? +现在题目要求:**已知有 `n` 层楼,`k` 个鸡蛋,求出至少需要扔几次鸡蛋,才能保证无论 `f` 是多少层,都能将 `f` 找出来?** 如果鸡蛋足够多(大于等于 $\log_2 n$ 个),可以通过二分查找的方法来测试。如果鸡蛋不够多,可能二分查找过程中,鸡蛋就用没了,则不能通过二分查找的方法来测试。 -那么这时候为了找出 `f` ,我们应该如何求出最少的扔鸡蛋次数。 +那么这时候为了找出 `f` ,我们应该如何求出最少的扔鸡蛋次数? + +### 思路 1:动态规划(超时) 可以这样考虑。题目限定了 `n` 层楼,`k` 个鸡蛋。 @@ -146,7 +146,7 @@ class Solution: ### 思路 2:动态规划优化 -上一步中时间复杂度为 $O(n^2 \times k)$。根据 $n$ 的规模,提交上去补出意外的超时了。 +上一步中时间复杂度为 $O(n^2 \times k)$。根据 $n$ 的规模,提交上去不出意外的超时了。 我们可以观察一下上面的状态转移方程 $dp[i][j] = min_{1 \le x \le n} (max(dp[i - x][j], dp[x - 1][j - 1])) + 1$ 。 @@ -197,21 +197,55 @@ class Solution: ### 思路 3:动态规划 + 逆向思维 +再看一下我们现在的题目要求:已知有 `n` 层楼,`k` 个鸡蛋,求出至少需要扔几次鸡蛋,才能保证无论 `f` 是多少层,都能将 `f` 找出来? + +我们可以逆向转换一下思维,将题目转变为:**已知有 `k` 个鸡蛋,最多扔 `x` 次鸡蛋(碎没碎都算 `1` 次),求最多可以检测的多少层?** + +我们把未知条件「扔鸡蛋的次数」变为了已知条件,将「检测的楼层个数」变为了未知条件。 + +这样如果求出来的「检测的楼层个数」大于等于 `n`,则说明 `1` ~ `n` 层楼都考虑全了,`f` 值也就明确了。我们只需要从符合条件的情况中,找出「扔鸡蛋次数」最少的次数即可。 + +动态规划的具体步骤如下: + +###### 1. 划分阶段 + +按照鸡蛋个数、扔鸡蛋的次数进行阶段划分。 + +###### 2. 定义状态 + +定义状态 `dp[i][j]` 表示为:一共有 `i` 个鸡蛋,最多扔 `j` 次鸡蛋(碎没碎都算 `1` 次)的条件下,最多可以检测的楼层个数。 + +###### 3. 状态转移方程 + +我们现在有 `i` 个鸡蛋,`j` 次扔鸡蛋的机会,现在尝试在 `1` ~ `n` 层中的任意一层 `x` 扔鸡蛋: +1. 如果鸡蛋没碎,剩下 `i` 个鸡蛋,还有 `j - 1` 次扔鸡蛋的机会,最多可以检测 `dp[i][j - 1]` 层楼层。 +2. 如果鸡蛋碎了,剩下 `i - 1` 个鸡蛋,还有 `j - 1` 次扔鸡蛋的机会,最多可以检测 `dp[i - 1][j - 1]` 层楼层。 +3. 再加上我们扔鸡蛋的第 `x` 层,`i` 个鸡蛋,`j` 次扔鸡蛋的机会最多可以检测 `dp[i][j - 1] + dp[i - 1][j - 1] + 1` 层。 + +则状态转移方程为:$dp[i][j] = dp[i][j - 1] + dp[i - 1][j - 1] + 1$。 + +###### 4. 初始条件 + +- 当鸡蛋数为 `1` 时,只有 `1` 次扔鸡蛋的机会时,最多可以检测 `1` 层,即 `dp[1][1] = 1`。 + +###### 5. 最终结果 + +根据我们之前定义的状态,`dp[i][j]` 表示为:一共有 `i` 个鸡蛋,最多扔 `j` 次鸡蛋(碎没碎都算 `1` 次)的条件下,最多可以检测的楼层个数。则我们需要从满足 `i == k` 并且 `dp[i][j] >= n`(即 `k` 个鸡蛋,`j` 次扔鸡蛋,一共检测出 `n` 层楼)的情况中,找出最小的 ` j`,将其返回。 ### 思路 3:代码 ```Python class Solution: def superEggDrop(self, k: int, n: int) -> int: - dp = [[i for _ in range(k + 1)] for i in range(n + 1)] + dp = [[0 for _ in range(n + 1)] for i in range(k + 1)] dp[1][1] = 1 - for i in range(1, n + 1): - for j in range(1, k + 1): - dp[i][j] = dp[i - 1][j] + dp[i - 1][j - 1] + 1 - if j == k and dp[i][j] >= n: - return i + for i in range(1, k + 1): + for j in range(1, n + 1): + dp[i][j] = dp[i][j - 1] + dp[i - 1][j - 1] + 1 + if i == k and dp[i][j] >= n: + return j return n ``` @@ -224,3 +258,4 @@ class Solution: - 【题解】[题目理解 + 基本解法 + 进阶解法 - 鸡蛋掉落 - 力扣](https://leetcode.cn/problems/super-egg-drop/solution/ji-ben-dong-tai-gui-hua-jie-fa-by-labuladong/) - 【题解】[动态规划(只解释官方题解方法一)(Java) - 鸡蛋掉落 - 力扣](https://leetcode.cn/problems/super-egg-drop/solution/dong-tai-gui-hua-zhi-jie-shi-guan-fang-ti-jie-fang/) +- 【题解】[动态规划 & 记忆化搜索 2000ms -> 32ms 的过程 - 鸡蛋掉落 - 力扣](https://leetcode.cn/problems/super-egg-drop/solution/python-dong-tai-gui-hua-ji-yi-hua-sou-su-hnj9/) From ef6bf4a6d1558e518dfe422e0b06cac941bb2f59 Mon Sep 17 00:00:00 2001 From: ITCharge Date: Wed, 10 Aug 2022 11:18:44 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E9=A2=98=E8=A7=A3?= =?UTF-8?q?=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Contents/00.Introduction/04.Solutions-List.md | 7 ++++++- Contents/00.Introduction/05.Categories-List.md | 6 +++--- Contents/00.Introduction/07.Interview-200-List.md | 2 +- .../03.Linear-DP/02.Linear-DP-List.md | 4 ++-- .../10.Probability-DP/02.Probability-DP-List.md | 2 +- README.md | 2 +- 6 files changed, 14 insertions(+), 9 deletions(-) diff --git a/Contents/00.Introduction/04.Solutions-List.md b/Contents/00.Introduction/04.Solutions-List.md index dcbae656..96c2b240 100644 --- a/Contents/00.Introduction/04.Solutions-List.md +++ b/Contents/00.Introduction/04.Solutions-List.md @@ -1,4 +1,4 @@ -# LeetCode 题解(已完成 725 道) +# LeetCode 题解(已完成 730 道) | 题号 | 标题 | 题解 | 标签 | 难度 | | :------ | :------ | :------ | :------ | :------ | @@ -354,6 +354,7 @@ | 0683 | [K 个关闭的灯泡](https://leetcode.cn/problems/k-empty-slots/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0683.%20K%20%E4%B8%AA%E5%85%B3%E9%97%AD%E7%9A%84%E7%81%AF%E6%B3%A1.md) | 树状数组、数组、有序集合、滑动窗口 | 困难 | | 0684 | [冗余连接](https://leetcode.cn/problems/redundant-connection/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0684.%20%E5%86%97%E4%BD%99%E8%BF%9E%E6%8E%A5.md) | 深度优先搜索、广度优先搜索、并查集、图 | 中等 | | 0686 | [重复叠加字符串匹配](https://leetcode.cn/problems/repeated-string-match/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0686.%20%E9%87%8D%E5%A4%8D%E5%8F%A0%E5%8A%A0%E5%AD%97%E7%AC%A6%E4%B8%B2%E5%8C%B9%E9%85%8D.md) | 字符串、字符串匹配 | 中等 | +| 0688 | [骑士在棋盘上的概率](https://leetcode.cn/problems/knight-probability-in-chessboard/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0688.%20%E9%AA%91%E5%A3%AB%E5%9C%A8%E6%A3%8B%E7%9B%98%E4%B8%8A%E7%9A%84%E6%A6%82%E7%8E%87.md) | 动态规划 | 中等 | | 0690 | [员工的重要性](https://leetcode.cn/problems/employee-importance/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0690.%20%E5%91%98%E5%B7%A5%E7%9A%84%E9%87%8D%E8%A6%81%E6%80%A7.md) | 深度优先搜索、广度优先搜索、哈希表 | 简单 | | 0695 | [岛屿的最大面积](https://leetcode.cn/problems/max-area-of-island/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0695.%20%E5%B2%9B%E5%B1%BF%E7%9A%84%E6%9C%80%E5%A4%A7%E9%9D%A2%E7%A7%AF.md) | 搜索 | 中等 | | 0700 | [二叉搜索树中的搜索](https://leetcode.cn/problems/search-in-a-binary-search-tree/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0700.%20%E4%BA%8C%E5%8F%89%E6%90%9C%E7%B4%A2%E6%A0%91%E4%B8%AD%E7%9A%84%E6%90%9C%E7%B4%A2.md) | 树 | 简单 | @@ -365,6 +366,7 @@ | 0706 | [设计哈希映射](https://leetcode.cn/problems/design-hashmap/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0706.%20%E8%AE%BE%E8%AE%A1%E5%93%88%E5%B8%8C%E6%98%A0%E5%B0%84.md) | 哈希表 | 简单 | | 0707 | [设计链表](https://leetcode.cn/problems/design-linked-list/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0707.%20%E8%AE%BE%E8%AE%A1%E9%93%BE%E8%A1%A8.md) | 链表 | 中等 | | 0708 | [循环有序列表的插入](https://leetcode.cn/problems/insert-into-a-sorted-circular-linked-list/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0708.%20%E5%BE%AA%E7%8E%AF%E6%9C%89%E5%BA%8F%E5%88%97%E8%A1%A8%E7%9A%84%E6%8F%92%E5%85%A5.md) | 链表 | 中等 | +| 0709 | [转换成小写字母](https://leetcode.cn/problems/to-lower-case/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0709.%20%E8%BD%AC%E6%8D%A2%E6%88%90%E5%B0%8F%E5%86%99%E5%AD%97%E6%AF%8D.md) | 字符串 | 简单 | | 0713 | [乘积小于K的子数组](https://leetcode.cn/problems/subarray-product-less-than-k/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0713.%20%E4%B9%98%E7%A7%AF%E5%B0%8F%E4%BA%8EK%E7%9A%84%E5%AD%90%E6%95%B0%E7%BB%84.md) | 数组、滑动窗口 | 中等 | | 0714 | [买卖股票的最佳时机含手续费](https://leetcode.cn/problems/best-time-to-buy-and-sell-stock-with-transaction-fee/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0714.%20%E4%B9%B0%E5%8D%96%E8%82%A1%E7%A5%A8%E7%9A%84%E6%9C%80%E4%BD%B3%E6%97%B6%E6%9C%BA%E5%90%AB%E6%89%8B%E7%BB%AD%E8%B4%B9.md) | 贪心、数组、动态规划 | 中等 | | 0715 | [Range 模块](https://leetcode.cn/problems/range-module/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0715.%20Range%20%E6%A8%A1%E5%9D%97.md) | 设计、线段树、有序集合 | 困难 | @@ -420,6 +422,7 @@ | 0877 | [石子游戏](https://leetcode.cn/problems/stone-game) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0877.%20%E7%9F%B3%E5%AD%90%E6%B8%B8%E6%88%8F.md) | 数组、数学、动态规划、博弈 | 中等 | | 0881 | [救生艇](https://leetcode.cn/problems/boats-to-save-people/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0881.%20%E6%95%91%E7%94%9F%E8%89%87.md) | 贪心、数组、双指针、排序 | 中等 | | 0886 | [可能的二分法](https://leetcode.cn/problems/possible-bipartition/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0886.%20%E5%8F%AF%E8%83%BD%E7%9A%84%E4%BA%8C%E5%88%86%E6%B3%95.md) | 深度优先搜索、广度优先搜索、并查集、图 | 中等 | +| 0887 | [鸡蛋掉落](https://leetcode.cn/problems/super-egg-drop/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0887.%20%E9%B8%A1%E8%9B%8B%E6%8E%89%E8%90%BD.md) | 数学、二分查找、动态规划 | 困难 | | 0889 | [根据前序和后序遍历构造二叉树](https://leetcode.cn/problems/construct-binary-tree-from-preorder-and-postorder-traversal/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0889.%20%E6%A0%B9%E6%8D%AE%E5%89%8D%E5%BA%8F%E5%92%8C%E5%90%8E%E5%BA%8F%E9%81%8D%E5%8E%86%E6%9E%84%E9%80%A0%E4%BA%8C%E5%8F%89%E6%A0%91.md) | 树、数组、哈希表、分治、二叉树 | 中等 | | 0897 | [递增顺序搜索树](https://leetcode.cn/problems/increasing-order-search-tree/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0897.%20%E9%80%92%E5%A2%9E%E9%A1%BA%E5%BA%8F%E6%90%9C%E7%B4%A2%E6%A0%91.md) | 栈、树、深度优先搜索、二叉搜索树、二叉树 | 简单 | | 0901 | [股票价格跨度](https://leetcode.cn/problems/online-stock-span/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0901.%20%E8%82%A1%E7%A5%A8%E4%BB%B7%E6%A0%BC%E8%B7%A8%E5%BA%A6.md) | 栈、设计、数据流、单调栈 | 中等 | @@ -515,6 +518,7 @@ | 1605 | [给定行和列的和求可行矩阵](https://leetcode.cn/problems/find-valid-matrix-given-row-and-column-sums/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/1605.%20%E7%BB%99%E5%AE%9A%E8%A1%8C%E5%92%8C%E5%88%97%E7%9A%84%E5%92%8C%E6%B1%82%E5%8F%AF%E8%A1%8C%E7%9F%A9%E9%98%B5.md) | 贪心、数组、矩阵 | 中等 | | 1631 | [最小体力消耗路径](https://leetcode.cn/problems/path-with-minimum-effort/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/1631.%20%E6%9C%80%E5%B0%8F%E4%BD%93%E5%8A%9B%E6%B6%88%E8%80%97%E8%B7%AF%E5%BE%84.md) | 深度优先搜索、广度优先搜索、并查集、数组、二分查找、矩阵、堆(优先队列) | 中等 | | 1658 | [将 x 减到 0 的最小操作数](https://leetcode.cn/problems/minimum-operations-to-reduce-x-to-zero/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/1658.%20%E5%B0%86%20x%20%E5%87%8F%E5%88%B0%200%20%E7%9A%84%E6%9C%80%E5%B0%8F%E6%93%8D%E4%BD%9C%E6%95%B0.md) | 数组、哈希表、二分查找、前缀和、滑动窗口 | 中等 | +| 1672 | [最富有客户的资产总量](https://leetcode.cn/problems/richest-customer-wealth/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/1672.%20%E6%9C%80%E5%AF%8C%E6%9C%89%E5%AE%A2%E6%88%B7%E7%9A%84%E8%B5%84%E4%BA%A7%E6%80%BB%E9%87%8F.md) | 数组、矩阵 | 简单 | | 1695 | [删除子数组的最大得分](https://leetcode.cn/problems/maximum-erasure-value/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/1695.%20%E5%88%A0%E9%99%A4%E5%AD%90%E6%95%B0%E7%BB%84%E7%9A%84%E6%9C%80%E5%A4%A7%E5%BE%97%E5%88%86.md) | 数组、哈希表、滑动窗口 | 中等 | | 1698 | [字符串的不同子字符串个数](https://leetcode.cn/problems/number-of-distinct-substrings-in-a-string/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/1698.%20%E5%AD%97%E7%AC%A6%E4%B8%B2%E7%9A%84%E4%B8%8D%E5%90%8C%E5%AD%90%E5%AD%97%E7%AC%A6%E4%B8%B2%E4%B8%AA%E6%95%B0.md) | 字典树、字符串、后缀数组、哈希函数、滚动哈希 | 中等 | | 1710 | [卡车上的最大单元数](https://leetcode.cn/problems/maximum-units-on-a-truck/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/1710.%20%E5%8D%A1%E8%BD%A6%E4%B8%8A%E7%9A%84%E6%9C%80%E5%A4%A7%E5%8D%95%E5%85%83%E6%95%B0.md) | 贪心、数组、排序 | 简单 | @@ -527,6 +531,7 @@ | 1929 | [数组串联](https://leetcode.cn/problems/concatenation-of-array/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/1929.%20%E6%95%B0%E7%BB%84%E4%B8%B2%E8%81%94.md) | 数组 | 简单 | | 2011 | [执行操作后的变量值](https://leetcode.cn/problems/final-value-of-variable-after-performing-operations/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/2011.%20%E6%89%A7%E8%A1%8C%E6%93%8D%E4%BD%9C%E5%90%8E%E7%9A%84%E5%8F%98%E9%87%8F%E5%80%BC.md) | 数组、字符串、模拟 | 简单 | | 2156 | [查找给定哈希值的子串](https://leetcode.cn/problems/find-substring-with-given-hash-value/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/2156.%20%E6%9F%A5%E6%89%BE%E7%BB%99%E5%AE%9A%E5%93%88%E5%B8%8C%E5%80%BC%E7%9A%84%E5%AD%90%E4%B8%B2.md) | 字符串、滑动窗口、哈希函数、滚动哈希 | 中等 | +| 2235 | [两整数相加](https://leetcode.cn/problems/add-two-integers/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/2235.%20%E4%B8%A4%E6%95%B4%E6%95%B0%E7%9B%B8%E5%8A%A0.md) | 数学 | 简单 | | 2276 | [统计区间中的整数数目](https://leetcode.cn/problems/count-integers-in-intervals/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/2276.%20%E7%BB%9F%E8%AE%A1%E5%8C%BA%E9%97%B4%E4%B8%AD%E7%9A%84%E6%95%B4%E6%95%B0%E6%95%B0%E7%9B%AE.md) | 设计、线段树、有序集合 | 困难 | | 剑指 Offer 03 | [数组中重复的数字](https://leetcode.cn/problems/shu-zu-zhong-zhong-fu-de-shu-zi-lcof/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/%E5%89%91%E6%8C%87%20Offer%2003.%20%E6%95%B0%E7%BB%84%E4%B8%AD%E9%87%8D%E5%A4%8D%E7%9A%84%E6%95%B0%E5%AD%97.md) | 数组、哈希表、排序 | 简单 | | 剑指 Offer 04 | [二维数组中的查找](https://leetcode.cn/problems/er-wei-shu-zu-zhong-de-cha-zhao-lcof/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/%E5%89%91%E6%8C%87%20Offer%2004.%20%E4%BA%8C%E7%BB%B4%E6%95%B0%E7%BB%84%E4%B8%AD%E7%9A%84%E6%9F%A5%E6%89%BE.md) | 数组、二分查找、分治、矩阵 | 中等 | diff --git a/Contents/00.Introduction/05.Categories-List.md b/Contents/00.Introduction/05.Categories-List.md index 066ebf9a..9f50f4ff 100644 --- a/Contents/00.Introduction/05.Categories-List.md +++ b/Contents/00.Introduction/05.Categories-List.md @@ -859,7 +859,7 @@ | 0639 | [解码方法 II](https://leetcode.cn/problems/decode-ways-ii/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0639.%20%E8%A7%A3%E7%A0%81%E6%96%B9%E6%B3%95%20II.md) | 字符串、动态规划 | 困难 | | 0650 | [只有两个键的键盘](https://leetcode.cn/problems/2-keys-keyboard/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0650.%20%E5%8F%AA%E6%9C%89%E4%B8%A4%E4%B8%AA%E9%94%AE%E7%9A%84%E9%94%AE%E7%9B%98.md) | 数学、动态规划 | 中等 | | 0678 | [有效的括号字符串](https://leetcode.cn/problems/valid-parenthesis-string/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0678.%20%E6%9C%89%E6%95%88%E7%9A%84%E6%8B%AC%E5%8F%B7%E5%AD%97%E7%AC%A6%E4%B8%B2.md) | 栈、贪心、字符串、动态规划 | 中等 | -| 0688 | 骑士在棋盘上的概率 | | | | +| 0688 | [骑士在棋盘上的概率](https://leetcode.cn/problems/knight-probability-in-chessboard/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0688.%20%E9%AA%91%E5%A3%AB%E5%9C%A8%E6%A3%8B%E7%9B%98%E4%B8%8A%E7%9A%84%E6%A6%82%E7%8E%87.md) | 动态规划 | 中等 | | 1137 | [第 N 个泰波那契数](https://leetcode.cn/problems/n-th-tribonacci-number) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/1137.%20%E7%AC%AC%20N%20%E4%B8%AA%E6%B3%B0%E6%B3%A2%E9%82%A3%E5%A5%91%E6%95%B0.md) | 记忆化搜索、数学、动态规划 | 简单 | | 1220 | [统计元音字母序列的数目](https://leetcode.cn/problems/count-vowels-permutation/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/1220.%20%E7%BB%9F%E8%AE%A1%E5%85%83%E9%9F%B3%E5%AD%97%E6%AF%8D%E5%BA%8F%E5%88%97%E7%9A%84%E6%95%B0%E7%9B%AE.md) | 动态规划 | 困难 | | 1751 | 最多可以参加的会议数目 II | | | | @@ -870,7 +870,7 @@ | 0120 | [三角形最小路径和](https://leetcode.cn/problems/triangle/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0120.%20%E4%B8%89%E8%A7%92%E5%BD%A2%E6%9C%80%E5%B0%8F%E8%B7%AF%E5%BE%84%E5%92%8C.md) | 数组、动态规划 | 中等 | | 0053 | [最大子数组和](https://leetcode.cn/problems/maximum-subarray/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0053.%20%E6%9C%80%E5%A4%A7%E5%AD%90%E6%95%B0%E7%BB%84%E5%92%8C.md) | 数组、分治算法、动态规划 | 简单 | | 0152 | [乘积最大子数组](https://leetcode.cn/problems/maximum-product-subarray/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0152.%20%E4%B9%98%E7%A7%AF%E6%9C%80%E5%A4%A7%E5%AD%90%E6%95%B0%E7%BB%84.md) | 数组、动态规划 | 中等 | -| 0887 | 鸡蛋掉落 | | | | +| 0887 | [鸡蛋掉落](https://leetcode.cn/problems/super-egg-drop/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0887.%20%E9%B8%A1%E8%9B%8B%E6%8E%89%E8%90%BD.md) | 数学、二分查找、动态规划 | 困难 | | 0072 | [编辑距离](https://leetcode.cn/problems/edit-distance/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0072.%20%E7%BC%96%E8%BE%91%E8%B7%9D%E7%A6%BB.md) | 字符串、动态规划 | 困难 | | 0044 | [通配符匹配](https://leetcode.cn/problems/wildcard-matching/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0044.%20%E9%80%9A%E9%85%8D%E7%AC%A6%E5%8C%B9%E9%85%8D.md) | 贪心、递归、字符串、动态规划 | 困难 | | 0010 | [正则表达式匹配](https://leetcode.cn/problems/regular-expression-matching/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0010.%20%E6%AD%A3%E5%88%99%E8%A1%A8%E8%BE%BE%E5%BC%8F%E5%8C%B9%E9%85%8D.md) | 递归、字符串、动态规划 | 困难 | @@ -955,7 +955,7 @@ | 题号 | 标题 | 题解 | 标签 | 难度 | | :------ | :------ | :------ | :------ | :------ | -| 0688 | 骑士在棋盘上的概率 | | | | +| 0688 | [骑士在棋盘上的概率](https://leetcode.cn/problems/knight-probability-in-chessboard/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0688.%20%E9%AA%91%E5%A3%AB%E5%9C%A8%E6%A3%8B%E7%9B%98%E4%B8%8A%E7%9A%84%E6%A6%82%E7%8E%87.md) | 动态规划 | 中等 | | 0808 | 分汤 | | | | | 0837 | 新 21 点 | | | | diff --git a/Contents/00.Introduction/07.Interview-200-List.md b/Contents/00.Introduction/07.Interview-200-List.md index 77f42896..bb2113c6 100644 --- a/Contents/00.Introduction/07.Interview-200-List.md +++ b/Contents/00.Introduction/07.Interview-200-List.md @@ -494,7 +494,7 @@ | 0044 | [通配符匹配](https://leetcode.cn/problems/wildcard-matching/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0044.%20%E9%80%9A%E9%85%8D%E7%AC%A6%E5%8C%B9%E9%85%8D.md) | 贪心、递归、字符串、动态规划 | 困难 | | 0120 | [三角形最小路径和](https://leetcode.cn/problems/triangle/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0120.%20%E4%B8%89%E8%A7%92%E5%BD%A2%E6%9C%80%E5%B0%8F%E8%B7%AF%E5%BE%84%E5%92%8C.md) | 数组、动态规划 | 中等 | | 0096 | [不同的二叉搜索树](https://leetcode.cn/problems/unique-binary-search-trees/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0096.%20%E4%B8%8D%E5%90%8C%E7%9A%84%E4%BA%8C%E5%8F%89%E6%90%9C%E7%B4%A2%E6%A0%91.md) | 树、二叉搜索树、数学、动态规划、二叉树 | 中等 | -| 0887 | 鸡蛋掉落 | | | | +| 0887 | [鸡蛋掉落](https://leetcode.cn/problems/super-egg-drop/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0887.%20%E9%B8%A1%E8%9B%8B%E6%8E%89%E8%90%BD.md) | 数学、二分查找、动态规划 | 困难 | | 0097 | 交错字符串 | | | | | 0516 | [最长回文子序列](https://leetcode.cn/problems/longest-palindromic-subsequence/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0516.%20%E6%9C%80%E9%95%BF%E5%9B%9E%E6%96%87%E5%AD%90%E5%BA%8F%E5%88%97.md) | 字符串、动态规划 | 中等 | diff --git a/Contents/10.Dynamic-Programming/03.Linear-DP/02.Linear-DP-List.md b/Contents/10.Dynamic-Programming/03.Linear-DP/02.Linear-DP-List.md index 36005ad2..be79b7c1 100644 --- a/Contents/10.Dynamic-Programming/03.Linear-DP/02.Linear-DP-List.md +++ b/Contents/10.Dynamic-Programming/03.Linear-DP/02.Linear-DP-List.md @@ -15,7 +15,7 @@ | 0639 | [解码方法 II](https://leetcode.cn/problems/decode-ways-ii/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0639.%20%E8%A7%A3%E7%A0%81%E6%96%B9%E6%B3%95%20II.md) | 字符串、动态规划 | 困难 | | 0650 | [只有两个键的键盘](https://leetcode.cn/problems/2-keys-keyboard/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0650.%20%E5%8F%AA%E6%9C%89%E4%B8%A4%E4%B8%AA%E9%94%AE%E7%9A%84%E9%94%AE%E7%9B%98.md) | 数学、动态规划 | 中等 | | 0678 | [有效的括号字符串](https://leetcode.cn/problems/valid-parenthesis-string/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0678.%20%E6%9C%89%E6%95%88%E7%9A%84%E6%8B%AC%E5%8F%B7%E5%AD%97%E7%AC%A6%E4%B8%B2.md) | 栈、贪心、字符串、动态规划 | 中等 | -| 0688 | 骑士在棋盘上的概率 | | | | +| 0688 | [骑士在棋盘上的概率](https://leetcode.cn/problems/knight-probability-in-chessboard/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0688.%20%E9%AA%91%E5%A3%AB%E5%9C%A8%E6%A3%8B%E7%9B%98%E4%B8%8A%E7%9A%84%E6%A6%82%E7%8E%87.md) | 动态规划 | 中等 | | 1137 | [第 N 个泰波那契数](https://leetcode.cn/problems/n-th-tribonacci-number) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/1137.%20%E7%AC%AC%20N%20%E4%B8%AA%E6%B3%B0%E6%B3%A2%E9%82%A3%E5%A5%91%E6%95%B0.md) | 记忆化搜索、数学、动态规划 | 简单 | | 1220 | [统计元音字母序列的数目](https://leetcode.cn/problems/count-vowels-permutation/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/1220.%20%E7%BB%9F%E8%AE%A1%E5%85%83%E9%9F%B3%E5%AD%97%E6%AF%8D%E5%BA%8F%E5%88%97%E7%9A%84%E6%95%B0%E7%9B%AE.md) | 动态规划 | 困难 | | 1751 | 最多可以参加的会议数目 II | | | | @@ -26,7 +26,7 @@ | 0120 | [三角形最小路径和](https://leetcode.cn/problems/triangle/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0120.%20%E4%B8%89%E8%A7%92%E5%BD%A2%E6%9C%80%E5%B0%8F%E8%B7%AF%E5%BE%84%E5%92%8C.md) | 数组、动态规划 | 中等 | | 0053 | [最大子数组和](https://leetcode.cn/problems/maximum-subarray/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0053.%20%E6%9C%80%E5%A4%A7%E5%AD%90%E6%95%B0%E7%BB%84%E5%92%8C.md) | 数组、分治算法、动态规划 | 简单 | | 0152 | [乘积最大子数组](https://leetcode.cn/problems/maximum-product-subarray/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0152.%20%E4%B9%98%E7%A7%AF%E6%9C%80%E5%A4%A7%E5%AD%90%E6%95%B0%E7%BB%84.md) | 数组、动态规划 | 中等 | -| 0887 | 鸡蛋掉落 | | | | +| 0887 | [鸡蛋掉落](https://leetcode.cn/problems/super-egg-drop/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0887.%20%E9%B8%A1%E8%9B%8B%E6%8E%89%E8%90%BD.md) | 数学、二分查找、动态规划 | 困难 | | 0072 | [编辑距离](https://leetcode.cn/problems/edit-distance/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0072.%20%E7%BC%96%E8%BE%91%E8%B7%9D%E7%A6%BB.md) | 字符串、动态规划 | 困难 | | 0044 | [通配符匹配](https://leetcode.cn/problems/wildcard-matching/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0044.%20%E9%80%9A%E9%85%8D%E7%AC%A6%E5%8C%B9%E9%85%8D.md) | 贪心、递归、字符串、动态规划 | 困难 | | 0010 | [正则表达式匹配](https://leetcode.cn/problems/regular-expression-matching/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0010.%20%E6%AD%A3%E5%88%99%E8%A1%A8%E8%BE%BE%E5%BC%8F%E5%8C%B9%E9%85%8D.md) | 递归、字符串、动态规划 | 困难 | diff --git a/Contents/10.Dynamic-Programming/10.Probability-DP/02.Probability-DP-List.md b/Contents/10.Dynamic-Programming/10.Probability-DP/02.Probability-DP-List.md index 8a4fd66a..23c91462 100644 --- a/Contents/10.Dynamic-Programming/10.Probability-DP/02.Probability-DP-List.md +++ b/Contents/10.Dynamic-Programming/10.Probability-DP/02.Probability-DP-List.md @@ -2,7 +2,7 @@ | 题号 | 标题 | 题解 | 标签 | 难度 | | :------ | :------ | :------ | :------ | :------ | -| 0688 | 骑士在棋盘上的概率 | | | | +| 0688 | [骑士在棋盘上的概率](https://leetcode.cn/problems/knight-probability-in-chessboard/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0688.%20%E9%AA%91%E5%A3%AB%E5%9C%A8%E6%A3%8B%E7%9B%98%E4%B8%8A%E7%9A%84%E6%A6%82%E7%8E%87.md) | 动态规划 | 中等 | | 0808 | 分汤 | | | | | 0837 | 新 21 点 | | | | diff --git a/README.md b/README.md index 756c62e1..89adaead 100644 --- a/README.md +++ b/README.md @@ -254,4 +254,4 @@ - [动态规划优化题目](./Contents/10.Dynamic-Programming/11.DP-Optimization/04.DP-Optimization-List.md) ## 11. 附加内容 -## [12. LeetCode 题解(已完成 725 道)](./Contents/00.Introduction/04.Solutions-List.md) \ No newline at end of file +## [12. LeetCode 题解(已完成 730 道)](./Contents/00.Introduction/04.Solutions-List.md) \ No newline at end of file