From b8e5c69a86c001c26b7b605fe7e1eb5e67c6d66b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E4=B8=96=E8=B6=85?= Date: 2022年6月20日 10:19:40 +0800 Subject: [PATCH 1/4] =?UTF-8?q?Create=200384.=20=E6=89=93=E4=B9=B1?= =?UTF-8?q?=E6=95=B0=E7=BB=84.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...23344円271円261円346円225円260円347円273円204円.md" | 75 +++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 "Solutions/0384. 346円211円223円344円271円261円346円225円260円347円273円204円.md" diff --git "a/Solutions/0384. 346円211円223円344円271円261円346円225円260円347円273円204円.md" "b/Solutions/0384. 346円211円223円344円271円261円346円225円260円347円273円204円.md" new file mode 100644 index 00000000..21b51e34 --- /dev/null +++ "b/Solutions/0384. 346円211円223円344円271円261円346円225円260円347円273円204円.md" @@ -0,0 +1,75 @@ +## [0384. 打乱数组](https://leetcode.cn/problems/shuffle-an-array/) + +- 标签:数组、数学、随机化 +- 难度:中等 + +## 题目大意 + +**描述**:给定一个整数数组 `nums`。 + +**要求**:设计算法来打乱一个没有重复元素的数组。打乱后,数组的所有排列应该是等可能的。 + +实现 `Solution class`: + +- `Solution(int[] nums)` 使用整数数组 `nums` 初始化对象。 +- `int[] reset()` 重设数组到它的初始状态并返回。 +- `int[] shuffle()` 返回数组随机打乱后的结果。 + +**说明**: + +- 1ドル \le nums.length \le 50$。 +- $-10^6 \le nums[i] \le 10^6$。 +- `nums` 中的所有元素都是 唯一的。 +- 最多可以调用 104 次 `reset` 和 `shuffle`。 + +**示例**: + +```Python +输入 +["Solution", "shuffle", "reset", "shuffle"] +[[[1, 2, 3]], [], [], []] +输出 +[null, [3, 1, 2], [1, 2, 3], [1, 3, 2]] + +解释 +Solution solution = new Solution([1, 2, 3]); +solution.shuffle(); // 打乱数组 [1,2,3] 并返回结果。任何 [1,2,3]的排列返回的概率应该相同。例如,返回 [3, 1, 2] +solution.reset(); // 重设数组到它的初始状态 [1, 2, 3] 。返回 [1, 2, 3] +solution.shuffle(); // 随机返回数组 [1, 2, 3] 打乱后的结果。例如,返回 [1, 3, 2] +``` + +## 解题思路 + +### 思路 1:洗牌算法 + +题目要求在打乱顺序后,数组的所有排列应该是等可能的。对于长度为 `n` 的数组,我们可以把问题转换为:分别在 `n` 个位置上,选择填入某个数的概率是相同。具体选择方法如下: + +- 对于第 `0` 个位置,我们从 `0 ~ n - 1` 总共 `n` 个数中随机选择一个数,将该数与第 `0` 个位置上的数进行交换。则每个数被选到的概率为 $\frac{1}{n}$。 +- 对于第 `1` 个位置,我们从剩下 `n - 1` 个数中随机选择一个数,将该数与第 `1` 个位置上的数进行交换。则每个数被选到的概率为 $\frac{n - 1}{n} \times \frac{1}{n - 1} = \frac{1}{n}$ (第一次没选到并且第二次被选中)。 +- 对于第 `2` 个位置,我们从剩下 `n - 2` 个数中随机选择一个数,将该数与第 `2` 个位置上的数进行交换。则每个数被选到的概率为 $\frac{n - 1}{n} \times \frac{n - 2}{n - 1} \times \frac{1}{n - 2} = \frac{1}{n}$ (第一次没选到、第二次没选到,并且第三次被选中)。 +- 依次类推,对于每个位置上,每个数被选中的概率都是 $\frac{1}{n}$。 + +### 思路 1:洗牌算法代码 + +```Python +class Solution: + + def __init__(self, nums: List[int]): + self.nums = nums + + + def reset(self) -> List[int]: + return self.nums + + + def shuffle(self) -> List[int]: + self.shuffle_nums = self.nums.copy() + for i in range(len(self.shuffle_nums)): + swap_index = random.randrange(i, len(self.shuffle_nums)) + self.shuffle_nums[i], self.shuffle_nums[swap_index] = self.shuffle_nums[swap_index], self.shuffle_nums[i] + return self.shuffle_nums +``` + +## 参考资料 + +- 【题解】[「Python/Java/JavaScript/Go」 洗牌算法 - 打乱数组 - 力扣](https://leetcode.cn/problems/shuffle-an-array/solution/pythonjavajavascriptgo-xi-pai-suan-fa-by-k7i2/) \ No newline at end of file From 8aac2680e0f725accc3708081f029ea038f622c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E4=B8=96=E8=B6=85?= Date: 2022年6月20日 13:43:43 +0800 Subject: [PATCH 2/4] =?UTF-8?q?Create=200443.=20=E5=8E=8B=E7=BC=A9?= =?UTF-8?q?=E5=AD=97=E7=AC=A6=E4=B8=B2.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...51345円255円227円347円254円246円344円270円262円.md" | 81 +++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 "Solutions/0443. 345円216円213円347円274円251円345円255円227円347円254円246円344円270円262円.md" diff --git "a/Solutions/0443. 345円216円213円347円274円251円345円255円227円347円254円246円344円270円262円.md" "b/Solutions/0443. 345円216円213円347円274円251円345円255円227円347円254円246円344円270円262円.md" new file mode 100644 index 00000000..a0084aa6 --- /dev/null +++ "b/Solutions/0443. 345円216円213円347円274円251円345円255円227円347円254円246円344円270円262円.md" @@ -0,0 +1,81 @@ +## [0443. 压缩字符串](https://leetcode.cn/problems/string-compression/) + +- 标签: +- 难度: + +## 题目大意 + +**描述**:给定一个字符数组 `chars`。请使用下述算法压缩: + +从一个空字符串 `s` 开始。对于 `chars` 中的每组连续重复字符: + +- 如果这一组长度为 `1`,则将字符追加到 `s` 中。 +- 如果这一组长度超过 `1`,则需要向 `s` 追加字符,后跟这一组的长度。 + +压缩后得到的字符串 `s` 不应该直接返回 ,需要转储到字符数组 `chars` 中。需要注意的是,如果组长度为 `10` 或 `10` 以上,则在 `chars` 数组中会被拆分为多个字符。 + +**要求**:在修改完输入数组后,返回该数组的新长度。 + +**说明**: + +- 1ドル \le chars.length \le 2000$。 +- `chars[i]` 可以是小写英文字母、大写英文字母、数字或符号。 +- 必须设计并实现一个只使用常量额外空间的算法来解决此问题。 + +**示例**: + +```Python +输入 chars = ["a","a","b","b","c","c","c"] +输出 返回 6 ,输入数组的前 6 个字符应该是:["a","2","b","2","c","3"] +解释 "aa" 被 "a2" 替代。"bb" 被 "b2" 替代。"ccc" 被 "c3" 替代。 +``` + +## 解题思路 + +### 思路 1:快慢指针 + +题目要求原地修改字符串数组。我们可以使用快慢指针来解决原地修改问题,具体解决方法如下: + +- 定义两个快慢指针 `slow`,`fast`。其中 `slow` 指向压缩后的当前字符位置,`fast` 指向压缩前的当前字符位置。 +- 记录下当前待压缩字符的起始位置 `fast_start = start`,然后过滤掉连续相同的字符。 +- 将待压缩字符的起始位置的字符存入压缩后的当前字符位置,即 `chars[slow] = chars[fast_start]`,并向右移动压缩后的当前字符位置,即 `slow += 1`。 +- 判断一下待压缩字符的数目是否大于 `1`: + - 如果数量为 `1`,则不用记录该数量。 + - 如果数量大于 `1`(即 `fast - fast_start> 0`),则我们需要将对应数量存入压缩后的当前字符位置。这时候还需要判断一下数量是否大于等于 `10`。 + - 如果数量大于等于 `10`,则需要先将数字从个位到高位转为字符,存入压缩后的当前字符位置(此时数字为反,比如原数字是 `321`,则此时存入后为 `123`)。因为数字为反,所以我们需要将对应位置上的子字符串进行反转。 + - 如果数量小于 `10`,则直接将数字存入压缩后的当前字符位置,无需取反。 +- 判断完之后向右移动压缩前的当前字符位置 `fast`,然后继续压缩字符串,直到全部压缩完,则返回压缩后的当前字符位置 `slow` 即为答案。 + +### 思路 1:快慢指针代码 + +```Python +class Solution: + + def compress(self, chars: List[str]) -> int: + def reverse(left, right): + while left < right: + chars[left], chars[right] = chars[right], chars[left] + left += 1 + right -= 1 + + slow, fast = 0, 0 + while fast < len(chars): + fast_start = fast + while fast + 1 < len(chars) and chars[fast + 1] == chars[fast]: + fast += 1 + + chars[slow] = chars[fast_start] + slow += 1 + + if fast - fast_start> 0: + cnt = fast - fast_start + 1 + slow_start = slow + while cnt != 0: + chars[slow] = str(cnt % 10) + slow += 1 + cnt = cnt // 10 + reverse(slow_start, slow - 1) + + fast += 1 + return slow +``` From b269de2eed01abf82011d129f33d5f9293106d5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E4=B8=96=E8=B6=85?= Date: 2022年6月20日 13:45:27 +0800 Subject: [PATCH 3/4] =?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 | 5 ++++- Contents/00.Introduction/05.Categories-List.md | 6 +++--- Contents/00.Introduction/07.Interview-200-List.md | 6 +++--- Contents/01.Array/02.Array-Sort/11.Array-Sort-List.md | 2 +- .../04.Array-Two-Pointers/02.Array-Two-Pointers-List.md | 2 +- README.md | 2 +- 6 files changed, 13 insertions(+), 10 deletions(-) diff --git a/Contents/00.Introduction/04.Solutions-List.md b/Contents/00.Introduction/04.Solutions-List.md index e9ba9b35..4ee52258 100644 --- a/Contents/00.Introduction/04.Solutions-List.md +++ b/Contents/00.Introduction/04.Solutions-List.md @@ -1,4 +1,4 @@ -# LeetCode 题解(已完成 708 道) +# LeetCode 题解(已完成 711 道) | 题号 | 标题 | 题解 | 标签 | 难度 | | :------ | :------ | :------ | :------ | :------ | @@ -61,6 +61,7 @@ | 0070 | [爬楼梯](https://leetcode.cn/problems/climbing-stairs/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0070.%20%E7%88%AC%E6%A5%BC%E6%A2%AF.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) | 字符串、动态规划 | 困难 | | 0073 | [矩阵置零](https://leetcode.cn/problems/set-matrix-zeroes/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0073.%20%E7%9F%A9%E9%98%B5%E7%BD%AE%E9%9B%B6.md) | 数组 | 中等 | +| 0074 | [搜索二维矩阵](https://leetcode.cn/problems/search-a-2d-matrix/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0074.%20%E6%90%9C%E7%B4%A2%E4%BA%8C%E7%BB%B4%E7%9F%A9%E9%98%B5.md) | 数组、二分查找、矩阵 | 中等 | | 0075 | [颜色分类](https://leetcode.cn/problems/sort-colors/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0075.%20%E9%A2%9C%E8%89%B2%E5%88%86%E7%B1%BB.md) | 数组、排序、双指针 | 中等 | | 0076 | [最小覆盖子串](https://leetcode.cn/problems/minimum-window-substring/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0076.%20%E6%9C%80%E5%B0%8F%E8%A6%86%E7%9B%96%E5%AD%90%E4%B8%B2.md) | 哈希表、字符串、滑动窗口 | 困难 | | 0077 | [组合](https://leetcode.cn/problems/combinations/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0077.%20%E7%BB%84%E5%90%88.md) | 数组、回溯 | 中等 | @@ -243,6 +244,7 @@ | 0378 | [有序矩阵中第 K 小的元素](https://leetcode.cn/problems/kth-smallest-element-in-a-sorted-matrix/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0378.%20%E6%9C%89%E5%BA%8F%E7%9F%A9%E9%98%B5%E4%B8%AD%E7%AC%AC%20K%20%E5%B0%8F%E7%9A%84%E5%85%83%E7%B4%A0.md) | 数组、二分查找、矩阵、排序、堆(优先队列) | 中等 | | 0380 | [常数时间插入、删除和获取随机元素](https://leetcode.cn/problems/insert-delete-getrandom-o1/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0380.%20%E5%B8%B8%E6%95%B0%E6%97%B6%E9%97%B4%E6%8F%92%E5%85%A5%E3%80%81%E5%88%A0%E9%99%A4%E5%92%8C%E8%8E%B7%E5%8F%96%E9%9A%8F%E6%9C%BA%E5%85%83%E7%B4%A0.md) | 数组、哈希表 | 中等 | | 0383 | [赎金信](https://leetcode.cn/problems/ransom-note) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0383.%20%E8%B5%8E%E9%87%91%E4%BF%A1.md) | 哈希表、字符串、计数 | 简单 | +| 0384 | [打乱数组](https://leetcode.cn/problems/shuffle-an-array/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0384.%20%E6%89%93%E4%B9%B1%E6%95%B0%E7%BB%84.md) | 数组、数学、随机化 | 中等 | | 0386 | [字典序排数](https://leetcode.cn/problems/lexicographical-numbers/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0386.%20%E5%AD%97%E5%85%B8%E5%BA%8F%E6%8E%92%E6%95%B0.md) | 深度优先搜索、字典树 | 中等 | | 0387 | [字符串中的第一个唯一字符](https://leetcode.cn/problems/first-unique-character-in-a-string/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0387.%20%E5%AD%97%E7%AC%A6%E4%B8%B2%E4%B8%AD%E7%9A%84%E7%AC%AC%E4%B8%80%E4%B8%AA%E5%94%AF%E4%B8%80%E5%AD%97%E7%AC%A6.md) | 字符串、哈希表 | 简单 | | 0389 | [找不同](https://leetcode.cn/problems/find-the-difference/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0389.%20%E6%89%BE%E4%B8%8D%E5%90%8C.md) | 位运算、哈希表 | 简单 | @@ -271,6 +273,7 @@ | 0435 | [无重叠区间](https://leetcode.cn/problems/non-overlapping-intervals/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0435.%20%E6%97%A0%E9%87%8D%E5%8F%A0%E5%8C%BA%E9%97%B4.md) | 贪心、数组、动态规划、排序 | 中等 | | 0437 | [路径总和 III](https://leetcode.cn/problems/path-sum-iii/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0437.%20%E8%B7%AF%E5%BE%84%E6%80%BB%E5%92%8C%20III.md) | 树、深度优先搜索、二叉树 | 中等 | | 0438 | [找到字符串中所有字母异位词](https://leetcode.cn/problems/find-all-anagrams-in-a-string/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0438.%20%E6%89%BE%E5%88%B0%E5%AD%97%E7%AC%A6%E4%B8%B2%E4%B8%AD%E6%89%80%E6%9C%89%E5%AD%97%E6%AF%8D%E5%BC%82%E4%BD%8D%E8%AF%8D.md) | 哈希表、字符串、滑动窗口 | 中等 | +| 0443 | [压缩字符串](https://leetcode.cn/problems/string-compression/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0443.%20%E5%8E%8B%E7%BC%A9%E5%AD%97%E7%AC%A6%E4%B8%B2.md) | | 简单 | | 0445 | [两数相加 II](https://leetcode.cn/problems/add-two-numbers-ii/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0445.%20%E4%B8%A4%E6%95%B0%E7%9B%B8%E5%8A%A0%20II.md) | 栈、链表、数学 | 中等 | | 0447 | [回旋镖的数量](https://leetcode.cn/problems/number-of-boomerangs/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0447.%20%E5%9B%9E%E6%97%8B%E9%95%96%E7%9A%84%E6%95%B0%E9%87%8F.md) | 哈希表、数学 | 中等 | | 0450 | [删除二叉搜索树中的节点](https://leetcode.cn/problems/delete-node-in-a-bst/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0450.%20%E5%88%A0%E9%99%A4%E4%BA%8C%E5%8F%89%E6%90%9C%E7%B4%A2%E6%A0%91%E4%B8%AD%E7%9A%84%E8%8A%82%E7%82%B9.md) | 树 | 中等 | diff --git a/Contents/00.Introduction/05.Categories-List.md b/Contents/00.Introduction/05.Categories-List.md index c5e2664f..916e4670 100644 --- a/Contents/00.Introduction/05.Categories-List.md +++ b/Contents/00.Introduction/05.Categories-List.md @@ -108,7 +108,7 @@ | 0136 | [只出现一次的数字](https://leetcode.cn/problems/single-number/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0136.%20%E5%8F%AA%E5%87%BA%E7%8E%B0%E4%B8%80%E6%AC%A1%E7%9A%84%E6%95%B0%E5%AD%97.md) | 位运算、数组 | 简单 | | 0056 | [合并区间](https://leetcode.cn/problems/merge-intervals/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0056.%20%E5%90%88%E5%B9%B6%E5%8C%BA%E9%97%B4.md) | 数组、排序 | 中等 | | 0179 | [最大数](https://leetcode.cn/problems/largest-number/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0179.%20%E6%9C%80%E5%A4%A7%E6%95%B0.md) | 贪心、字符串、排序 | 中等 | -| 0384 | 打乱数组 | | | | +| 0384 | [打乱数组](https://leetcode.cn/problems/shuffle-an-array/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0384.%20%E6%89%93%E4%B9%B1%E6%95%B0%E7%BB%84.md) | 数组、数学、随机化 | 中等 | | 剑指 Offer 45 | [把数组排成最小的数](https://leetcode.cn/problems/ba-shu-zu-pai-cheng-zui-xiao-de-shu-lcof/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/%E5%89%91%E6%8C%87%20Offer%2045.%20%E6%8A%8A%E6%95%B0%E7%BB%84%E6%8E%92%E6%88%90%E6%9C%80%E5%B0%8F%E7%9A%84%E6%95%B0.md) | 贪心、字符串、排序 | 中等 | ### 二分查找题目 @@ -132,7 +132,7 @@ | 1095 | [山脉数组中查找目标值](https://leetcode.cn/problems/find-in-mountain-array/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/1095.%20%E5%B1%B1%E8%84%89%E6%95%B0%E7%BB%84%E4%B8%AD%E6%9F%A5%E6%89%BE%E7%9B%AE%E6%A0%87%E5%80%BC.md) | 数组、二分查找、交互 | 困难 | | 0744 | [寻找比目标字母大的最小字母](https://leetcode.cn/problems/find-smallest-letter-greater-than-target/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0744.%20%E5%AF%BB%E6%89%BE%E6%AF%94%E7%9B%AE%E6%A0%87%E5%AD%97%E6%AF%8D%E5%A4%A7%E7%9A%84%E6%9C%80%E5%B0%8F%E5%AD%97%E6%AF%8D.md) | 二分查找 | 简单 | | 0004 | [寻找两个正序数组的中位数](https://leetcode.cn/problems/median-of-two-sorted-arrays/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0004.%20%E5%AF%BB%E6%89%BE%E4%B8%A4%E4%B8%AA%E6%AD%A3%E5%BA%8F%E6%95%B0%E7%BB%84%E7%9A%84%E4%B8%AD%E4%BD%8D%E6%95%B0.md) | 数组、二分查找、分治算法 | 困难 | -| 0074 | 搜索二维矩阵 | | | | +| 0074 | [搜索二维矩阵](https://leetcode.cn/problems/search-a-2d-matrix/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0074.%20%E6%90%9C%E7%B4%A2%E4%BA%8C%E7%BB%B4%E7%9F%A9%E9%98%B5.md) | 数组、二分查找、矩阵 | 中等 | | 0240 | [搜索二维矩阵 II](https://leetcode.cn/problems/search-a-2d-matrix-ii/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0240.%20%E6%90%9C%E7%B4%A2%E4%BA%8C%E7%BB%B4%E7%9F%A9%E9%98%B5%20II.md) | 二分查找、分治算法 | 中等 | #### 二分答案题目 @@ -188,7 +188,7 @@ | 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) | 贪心、数组、双指针、排序 | 中等 | | 0042 | [接雨水](https://leetcode.cn/problems/trapping-rain-water/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0042.%20%E6%8E%A5%E9%9B%A8%E6%B0%B4.md) | 栈、数组、双指针、动态规划、单调栈 | 困难 | | 剑指 Offer 21 | [调整数组顺序使奇数位于偶数前面](https://leetcode.cn/problems/diao-zheng-shu-zu-shun-xu-shi-qi-shu-wei-yu-ou-shu-qian-mian-lcof/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/%E5%89%91%E6%8C%87%20Offer%2021.%20%E8%B0%83%E6%95%B4%E6%95%B0%E7%BB%84%E9%A1%BA%E5%BA%8F%E4%BD%BF%E5%A5%87%E6%95%B0%E4%BD%8D%E4%BA%8E%E5%81%B6%E6%95%B0%E5%89%8D%E9%9D%A2.md) | 数组、双指针、排序 | 简单 | -| 0443 | 压缩字符串 | | | | +| 0443 | [压缩字符串](https://leetcode.cn/problems/string-compression/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0443.%20%E5%8E%8B%E7%BC%A9%E5%AD%97%E7%AC%A6%E4%B8%B2.md) | | 简单 | #### 快慢指针题目 diff --git a/Contents/00.Introduction/07.Interview-200-List.md b/Contents/00.Introduction/07.Interview-200-List.md index bc01af40..4954fed6 100644 --- a/Contents/00.Introduction/07.Interview-200-List.md +++ b/Contents/00.Introduction/07.Interview-200-List.md @@ -86,7 +86,7 @@ | 0136 | [只出现一次的数字](https://leetcode.cn/problems/single-number/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0136.%20%E5%8F%AA%E5%87%BA%E7%8E%B0%E4%B8%80%E6%AC%A1%E7%9A%84%E6%95%B0%E5%AD%97.md) | 位运算、数组 | 简单 | | 0056 | [合并区间](https://leetcode.cn/problems/merge-intervals/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0056.%20%E5%90%88%E5%B9%B6%E5%8C%BA%E9%97%B4.md) | 数组、排序 | 中等 | | 0179 | [最大数](https://leetcode.cn/problems/largest-number/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0179.%20%E6%9C%80%E5%A4%A7%E6%95%B0.md) | 贪心、字符串、排序 | 中等 | -| 0384 | 打乱数组 | | | | +| 0384 | [打乱数组](https://leetcode.cn/problems/shuffle-an-array/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0384.%20%E6%89%93%E4%B9%B1%E6%95%B0%E7%BB%84.md) | 数组、数学、随机化 | 中等 | | 剑指 Offer 45 | [把数组排成最小的数](https://leetcode.cn/problems/ba-shu-zu-pai-cheng-zui-xiao-de-shu-lcof/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/%E5%89%91%E6%8C%87%20Offer%2045.%20%E6%8A%8A%E6%95%B0%E7%BB%84%E6%8E%92%E6%88%90%E6%9C%80%E5%B0%8F%E7%9A%84%E6%95%B0.md) | 贪心、字符串、排序 | 中等 | ### 二分查找题目 @@ -102,7 +102,7 @@ | 0033 | [搜索旋转排序数组](https://leetcode.cn/problems/search-in-rotated-sorted-array/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0033.%20%E6%90%9C%E7%B4%A2%E6%97%8B%E8%BD%AC%E6%8E%92%E5%BA%8F%E6%95%B0%E7%BB%84.md) | 数组、二分查找 | 中等 | | 0162 | [寻找峰值](https://leetcode.cn/problems/find-peak-element/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0162.%20%E5%AF%BB%E6%89%BE%E5%B3%B0%E5%80%BC.md) | 数组、二分查找 | 中等 | | 0004 | [寻找两个正序数组的中位数](https://leetcode.cn/problems/median-of-two-sorted-arrays/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0004.%20%E5%AF%BB%E6%89%BE%E4%B8%A4%E4%B8%AA%E6%AD%A3%E5%BA%8F%E6%95%B0%E7%BB%84%E7%9A%84%E4%B8%AD%E4%BD%8D%E6%95%B0.md) | 数组、二分查找、分治算法 | 困难 | -| 0074 | 搜索二维矩阵 | | | | +| 0074 | [搜索二维矩阵](https://leetcode.cn/problems/search-a-2d-matrix/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0074.%20%E6%90%9C%E7%B4%A2%E4%BA%8C%E7%BB%B4%E7%9F%A9%E9%98%B5.md) | 数组、二分查找、矩阵 | 中等 | | 0240 | [搜索二维矩阵 II](https://leetcode.cn/problems/search-a-2d-matrix-ii/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0240.%20%E6%90%9C%E7%B4%A2%E4%BA%8C%E7%BB%B4%E7%9F%A9%E9%98%B5%20II.md) | 二分查找、分治算法 | 中等 | #### 二分答案题目 @@ -134,7 +134,7 @@ | 0011 | [盛最多水的容器](https://leetcode.cn/problems/container-with-most-water/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0011.%20%E7%9B%9B%E6%9C%80%E5%A4%9A%E6%B0%B4%E7%9A%84%E5%AE%B9%E5%99%A8.md) | 贪心、数组、双指针 | 中等 | | 0075 | [颜色分类](https://leetcode.cn/problems/sort-colors/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0075.%20%E9%A2%9C%E8%89%B2%E5%88%86%E7%B1%BB.md) | 数组、排序、双指针 | 中等 | | 剑指 Offer 21 | [调整数组顺序使奇数位于偶数前面](https://leetcode.cn/problems/diao-zheng-shu-zu-shun-xu-shi-qi-shu-wei-yu-ou-shu-qian-mian-lcof/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/%E5%89%91%E6%8C%87%20Offer%2021.%20%E8%B0%83%E6%95%B4%E6%95%B0%E7%BB%84%E9%A1%BA%E5%BA%8F%E4%BD%BF%E5%A5%87%E6%95%B0%E4%BD%8D%E4%BA%8E%E5%81%B6%E6%95%B0%E5%89%8D%E9%9D%A2.md) | 数组、双指针、排序 | 简单 | -| 0443 | 压缩字符串 | | | | +| 0443 | [压缩字符串](https://leetcode.cn/problems/string-compression/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0443.%20%E5%8E%8B%E7%BC%A9%E5%AD%97%E7%AC%A6%E4%B8%B2.md) | | 简单 | #### 快慢指针题目 diff --git a/Contents/01.Array/02.Array-Sort/11.Array-Sort-List.md b/Contents/01.Array/02.Array-Sort/11.Array-Sort-List.md index de62208b..3913a6ef 100644 --- a/Contents/01.Array/02.Array-Sort/11.Array-Sort-List.md +++ b/Contents/01.Array/02.Array-Sort/11.Array-Sort-List.md @@ -79,6 +79,6 @@ | 0136 | [只出现一次的数字](https://leetcode.cn/problems/single-number/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0136.%20%E5%8F%AA%E5%87%BA%E7%8E%B0%E4%B8%80%E6%AC%A1%E7%9A%84%E6%95%B0%E5%AD%97.md) | 位运算、数组 | 简单 | | 0056 | [合并区间](https://leetcode.cn/problems/merge-intervals/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0056.%20%E5%90%88%E5%B9%B6%E5%8C%BA%E9%97%B4.md) | 数组、排序 | 中等 | | 0179 | [最大数](https://leetcode.cn/problems/largest-number/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0179.%20%E6%9C%80%E5%A4%A7%E6%95%B0.md) | 贪心、字符串、排序 | 中等 | -| 0384 | 打乱数组 | | | | +| 0384 | [打乱数组](https://leetcode.cn/problems/shuffle-an-array/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0384.%20%E6%89%93%E4%B9%B1%E6%95%B0%E7%BB%84.md) | 数组、数学、随机化 | 中等 | | 剑指 Offer 45 | [把数组排成最小的数](https://leetcode.cn/problems/ba-shu-zu-pai-cheng-zui-xiao-de-shu-lcof/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/%E5%89%91%E6%8C%87%20Offer%2045.%20%E6%8A%8A%E6%95%B0%E7%BB%84%E6%8E%92%E6%88%90%E6%9C%80%E5%B0%8F%E7%9A%84%E6%95%B0.md) | 贪心、字符串、排序 | 中等 | diff --git a/Contents/01.Array/04.Array-Two-Pointers/02.Array-Two-Pointers-List.md b/Contents/01.Array/04.Array-Two-Pointers/02.Array-Two-Pointers-List.md index b5e91ce1..d90395d3 100644 --- a/Contents/01.Array/04.Array-Two-Pointers/02.Array-Two-Pointers-List.md +++ b/Contents/01.Array/04.Array-Two-Pointers/02.Array-Two-Pointers-List.md @@ -22,7 +22,7 @@ | 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) | 贪心、数组、双指针、排序 | 中等 | | 0042 | [接雨水](https://leetcode.cn/problems/trapping-rain-water/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0042.%20%E6%8E%A5%E9%9B%A8%E6%B0%B4.md) | 栈、数组、双指针、动态规划、单调栈 | 困难 | | 剑指 Offer 21 | [调整数组顺序使奇数位于偶数前面](https://leetcode.cn/problems/diao-zheng-shu-zu-shun-xu-shi-qi-shu-wei-yu-ou-shu-qian-mian-lcof/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/%E5%89%91%E6%8C%87%20Offer%2021.%20%E8%B0%83%E6%95%B4%E6%95%B0%E7%BB%84%E9%A1%BA%E5%BA%8F%E4%BD%BF%E5%A5%87%E6%95%B0%E4%BD%8D%E4%BA%8E%E5%81%B6%E6%95%B0%E5%89%8D%E9%9D%A2.md) | 数组、双指针、排序 | 简单 | -| 0443 | 压缩字符串 | | | | +| 0443 | [压缩字符串](https://leetcode.cn/problems/string-compression/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0443.%20%E5%8E%8B%E7%BC%A9%E5%AD%97%E7%AC%A6%E4%B8%B2.md) | | 简单 | #### 快慢指针题目 diff --git a/README.md b/README.md index 889fefae..6c101f20 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 题解(已完成 708 道)](./Contents/00.Introduction/04.Solutions-List.md) \ No newline at end of file +## [12. LeetCode 题解(已完成 711 道)](./Contents/00.Introduction/04.Solutions-List.md) \ No newline at end of file From 1685a25a0f5511657cb0fc58419a7bbc25e90032 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E4=B8=96=E8=B6=85?= Date: 2022年6月20日 13:51:14 +0800 Subject: [PATCH 4/4] Update 02.Array-Binary-Search-List.md --- .../03.Array-Binary-Search/02.Array-Binary-Search-List.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Contents/01.Array/03.Array-Binary-Search/02.Array-Binary-Search-List.md b/Contents/01.Array/03.Array-Binary-Search/02.Array-Binary-Search-List.md index b7ef51f8..3d6dbc47 100644 --- a/Contents/01.Array/03.Array-Binary-Search/02.Array-Binary-Search-List.md +++ b/Contents/01.Array/03.Array-Binary-Search/02.Array-Binary-Search-List.md @@ -19,7 +19,7 @@ | 1095 | [山脉数组中查找目标值](https://leetcode.cn/problems/find-in-mountain-array/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/1095.%20%E5%B1%B1%E8%84%89%E6%95%B0%E7%BB%84%E4%B8%AD%E6%9F%A5%E6%89%BE%E7%9B%AE%E6%A0%87%E5%80%BC.md) | 数组、二分查找、交互 | 困难 | | 0744 | [寻找比目标字母大的最小字母](https://leetcode.cn/problems/find-smallest-letter-greater-than-target/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0744.%20%E5%AF%BB%E6%89%BE%E6%AF%94%E7%9B%AE%E6%A0%87%E5%AD%97%E6%AF%8D%E5%A4%A7%E7%9A%84%E6%9C%80%E5%B0%8F%E5%AD%97%E6%AF%8D.md) | 二分查找 | 简单 | | 0004 | [寻找两个正序数组的中位数](https://leetcode.cn/problems/median-of-two-sorted-arrays/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0004.%20%E5%AF%BB%E6%89%BE%E4%B8%A4%E4%B8%AA%E6%AD%A3%E5%BA%8F%E6%95%B0%E7%BB%84%E7%9A%84%E4%B8%AD%E4%BD%8D%E6%95%B0.md) | 数组、二分查找、分治算法 | 困难 | -| 0074 | 搜索二维矩阵 | | | | +| 0074 | [搜索二维矩阵](https://leetcode.cn/problems/search-a-2d-matrix/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0074.%20%E6%90%9C%E7%B4%A2%E4%BA%8C%E7%BB%B4%E7%9F%A9%E9%98%B5.md) | 数组、二分查找、矩阵 | 中等 | | 0240 | [搜索二维矩阵 II](https://leetcode.cn/problems/search-a-2d-matrix-ii/) | [Python](https://github.com/itcharge/LeetCode-Py/blob/main/Solutions/0240.%20%E6%90%9C%E7%B4%A2%E4%BA%8C%E7%BB%B4%E7%9F%A9%E9%98%B5%20II.md) | 二分查找、分治算法 | 中等 | #### 二分答案题目

AltStyle によって変換されたページ (->オリジナル) /