diff --git a/Contents/00.Introduction/02.Algorithm-Complexity.md b/Contents/00.Introduction/02.Algorithm-Complexity.md
index 02744978..ae29debd 100644
--- a/Contents/00.Introduction/02.Algorithm-Complexity.md
+++ b/Contents/00.Introduction/02.Algorithm-Complexity.md
@@ -43,7 +43,7 @@
下面通过一个具体例子来说明一下如何计算时间复杂度。
-```Python
+```python
def algorithm(n):
fact = 1
for i in range(1, n + 1):
@@ -120,7 +120,7 @@ $\Theta$ 符号渐进地给出了一个函数的上界和下界,如果我们
$O(1)$ 只是常数阶时间复杂度的一种表示方式,并不是指只执行了一行代码。只要代码的执行时间不随着问题规模 n 的增大而增长,这样的算法时间复杂度都记为 $O(1)$。
-```Python
+```python
def algorithm(n):
a = 1
b = 2
@@ -134,7 +134,7 @@ def algorithm(n):
一般含有非嵌套循环,且单层循环下的语句执行次数为 n 的算法涉及线性时间复杂度。这类算法随着问题规模 n 的增大,对应计算次数呈线性增长。
-```Python
+```python
def algorithm(n):
sum = 0
for i in range(n):
@@ -149,7 +149,7 @@ def algorithm(n):
一般含有双层嵌套,且每层循环下的语句执行次数为 n 的算法涉及平方时间复杂度。这类算法随着问题规模 n 的增大,对应计算次数呈平方关系增长。
-```Python
+```python
def algorithm(n):
res = 0
for i in range(n):
@@ -164,7 +164,7 @@ def algorithm(n):
阶乘时间复杂度一般出现在与「全排列」、「旅行商问题暴力解法」相关的算法中。这类算法随着问题规模 n 的增大,对应计算次数呈阶乘关系增长。
-```Python
+```python
def permutations(arr, start, end):
if start == end:
print(arr)
@@ -182,7 +182,7 @@ def permutations(arr, start, end):
对数时间复杂度一般出现在「二分查找」、「分治」这种一分为二的算法中。这类算法随着问题规模 n 的增大,对应的计算次数呈对数关系增长。
-```Python
+```python
def algorithm(n):
cnt = 1
while cnt < n:
@@ -197,7 +197,7 @@ def algorithm(n):
线性对数一般出现在排序算法中,例如「快速排序」、「归并排序」、「堆排序」等。这类算法随着问题规模 n 的增大,对应的计算次数呈线性对数关系增长。
-```Python
+```python
def algorithm(n):
cnt = 1
res = 0
@@ -225,7 +225,7 @@ def algorithm(n):
我们通过一个例子来分析下最佳、最坏、最差时间复杂度。
-```Python
+```python
def find(nums, val):
pos = -1
for i in range(n):
@@ -263,7 +263,7 @@ def find(nums, val):
#### 3.1.1 常数 O(1)
-```Python
+```python
def algorithm(n):
a = 1
b = 2
@@ -275,7 +275,7 @@ def algorithm(n):
#### 3.1.2 线性 O(n)
-```Python
+```python
def algorithm(n):
if n <= 0:
return 1
diff --git a/Contents/00.Introduction/03.LeetCode-Guide.md b/Contents/00.Introduction/03.LeetCode-Guide.md
index 069873f5..1da45ce4 100644
--- a/Contents/00.Introduction/03.LeetCode-Guide.md
+++ b/Contents/00.Introduction/03.LeetCode-Guide.md
@@ -114,7 +114,7 @@ LeetCode 提供了题目的搜索过滤功能。可以筛选相关题单、不
1. 思路一:暴力搜索
-```Python
+```python
class Solution:
def twoSum(self, nums: List[int], target: int) -> List[int]:
size = len(nums)
@@ -127,7 +127,7 @@ class Solution:
2. 思路二:哈希表
-```Python
+```python
class Solution:
def twoSum(self, nums: List[int], target: int) -> List[int]:
size = len(nums)
diff --git a/Contents/01.Array/01.Array-Basic/01.Array-Basic.md b/Contents/01.Array/01.Array-Basic/01.Array-Basic.md
index 92815a16..33b72011 100644
--- a/Contents/01.Array/01.Array-Basic/01.Array-Basic.md
+++ b/Contents/01.Array/01.Array-Basic/01.Array-Basic.md
@@ -66,7 +66,7 @@ int[][] arr = new int[3][]{ {1,2,3}, {4,5}, {6,7,8,9}};
原生 `Python` 中其实没有数组的概念,而是使用了类似 `Java` 中的 `ArrayList` 容器类数据结构,叫做列表。通常我们把列表来作为 `Python` 中的数组使用。`Python` 中列表存储的数据类型可以不一致,数组长度也可以不一致。例如:
-```Python
+```python
arr = ['python', 'java', ['asp', 'php'], 'c']
```
@@ -80,7 +80,7 @@ arr = ['python', 'java', ['asp', 'php'], 'c']
示例代码如下:
-```Python
+```python
# 从数组 nums 中读取下标为 i 的数据元素值
def value(nums, i):
if 0 <= i <= len(nums) - 1:
@@ -96,7 +96,7 @@ value(arr, 3)
示例代码如下:
-```Python
+```python
# 从数组 nums 中查找元素值为 val 的数据元素第一次出现的位置
def find(nums, val):
for i in range(len(nums)):
@@ -120,7 +120,7 @@ print(find(arr, 5))
示例代码如下:
-```Python
+```python
arr = [0, 5, 2, 3, 7, 1, 6]
val = 4
arr.append(val)
@@ -135,7 +135,7 @@ print(arr)
示例代码如下:
-```Python
+```python
arr = [0, 5, 2, 3, 7, 1, 6]
i, val = 2, 4
arr.insert(i, val)
@@ -150,7 +150,7 @@ print(arr)
示例代码如下:
-```Python
+```python
def change(nums, i, val):
if 0 <= i <= len(nums) - 1:
nums[i] = val
@@ -173,7 +173,7 @@ print(arr)
示例代码如下:
-```Python
+```python
arr = [0, 5, 2, 3, 7, 1, 6]
arr.pop()
print(arr)
@@ -198,7 +198,7 @@ print(arr)
示例代码如下:
-```Python
+```python
arr = [0, 5, 2, 3, 7, 1, 6]
i = 3
arr.remove(5)
diff --git a/Contents/01.Array/02.Array-Sort/01.Array-Bubble-Sort.md b/Contents/01.Array/02.Array-Sort/01.Array-Bubble-Sort.md
index 5d6e4c1b..a310b530 100644
--- a/Contents/01.Array/02.Array-Sort/01.Array-Bubble-Sort.md
+++ b/Contents/01.Array/02.Array-Sort/01.Array-Bubble-Sort.md
@@ -49,7 +49,7 @@
## 5. 冒泡排序代码实现
-```Python
+```python
class Solution:
def bubbleSort(self, arr):
# 第 i 趟排序
diff --git a/Contents/01.Array/02.Array-Sort/02.Array-Selection-Sort.md b/Contents/01.Array/02.Array-Sort/02.Array-Selection-Sort.md
index 2a56e3bd..409952a3 100644
--- a/Contents/01.Array/02.Array-Sort/02.Array-Selection-Sort.md
+++ b/Contents/01.Array/02.Array-Sort/02.Array-Selection-Sort.md
@@ -44,7 +44,7 @@
## 5. 选择排序代码实现
-```Python
+```python
class Solution:
def selectionSort(self, arr):
for i in range(len(arr) - 1):
diff --git a/Contents/01.Array/02.Array-Sort/03.Array-Insertion-Sort.md b/Contents/01.Array/02.Array-Sort/03.Array-Insertion-Sort.md
index 75d8535d..90a16931 100644
--- a/Contents/01.Array/02.Array-Sort/03.Array-Insertion-Sort.md
+++ b/Contents/01.Array/02.Array-Sort/03.Array-Insertion-Sort.md
@@ -49,7 +49,7 @@
## 5. 插入排序代码实现
-```Python
+```python
class Solution:
def insertionSort(self, arr):
# 遍历无序序列
diff --git a/Contents/01.Array/02.Array-Sort/04.Array-Shell-Sort.md b/Contents/01.Array/02.Array-Sort/04.Array-Shell-Sort.md
index 2d38e00d..680b8522 100644
--- a/Contents/01.Array/02.Array-Sort/04.Array-Shell-Sort.md
+++ b/Contents/01.Array/02.Array-Sort/04.Array-Shell-Sort.md
@@ -27,7 +27,7 @@
## 5. 希尔排序代码实现
-```Python
+```python
class Solution:
def shellSort(self, arr):
size = len(arr)
diff --git a/Contents/01.Array/02.Array-Sort/05.Array-Merge-Sort.md b/Contents/01.Array/02.Array-Sort/05.Array-Merge-Sort.md
index 7cbb9a8b..d502c8ea 100644
--- a/Contents/01.Array/02.Array-Sort/05.Array-Merge-Sort.md
+++ b/Contents/01.Array/02.Array-Sort/05.Array-Merge-Sort.md
@@ -41,7 +41,7 @@
## 5. 归并排序代码实现
-```Python
+```python
class Solution:
def merge(self, left_arr, right_arr): # 归并过程
arr = []
diff --git a/Contents/01.Array/02.Array-Sort/06.Array-Quick-Sort.md b/Contents/01.Array/02.Array-Sort/06.Array-Quick-Sort.md
index 2c049c25..509d3a51 100644
--- a/Contents/01.Array/02.Array-Sort/06.Array-Quick-Sort.md
+++ b/Contents/01.Array/02.Array-Sort/06.Array-Quick-Sort.md
@@ -65,7 +65,7 @@
## 5. 快速排序代码实现
-```Python
+```python
import random
class Solution:
diff --git a/Contents/01.Array/02.Array-Sort/07.Array-Heap-Sort.md b/Contents/01.Array/02.Array-Sort/07.Array-Heap-Sort.md
index f7f6843b..d6f7343a 100644
--- a/Contents/01.Array/02.Array-Sort/07.Array-Heap-Sort.md
+++ b/Contents/01.Array/02.Array-Sort/07.Array-Heap-Sort.md
@@ -83,7 +83,7 @@
## 6. 堆排序代码实现
-```Python
+```python
class Solution:
# 调整为大顶堆
def heapify(self, arr: [int], index: int, end: int):
diff --git a/Contents/01.Array/02.Array-Sort/08.Array-Counting-Sort.md b/Contents/01.Array/02.Array-Sort/08.Array-Counting-Sort.md
index 5ccf2f18..d6f203f5 100644
--- a/Contents/01.Array/02.Array-Sort/08.Array-Counting-Sort.md
+++ b/Contents/01.Array/02.Array-Sort/08.Array-Counting-Sort.md
@@ -28,7 +28,7 @@
## 5. 计数排序代码实现
-```Python
+```python
class Solution:
def countingSort(self, arr):
# 计算待排序序列中最大值元素 arr_max 和最小值元素 arr_min
diff --git a/Contents/01.Array/02.Array-Sort/09.Array-Bucket-Sort.md b/Contents/01.Array/02.Array-Sort/09.Array-Bucket-Sort.md
index 3d1ef540..02492888 100644
--- a/Contents/01.Array/02.Array-Sort/09.Array-Bucket-Sort.md
+++ b/Contents/01.Array/02.Array-Sort/09.Array-Bucket-Sort.md
@@ -33,7 +33,7 @@
## 5. 桶排序代码实现
-```Python
+```python
class Solution:
def insertionSort(self, arr):
# 遍历无序序列
diff --git a/Contents/01.Array/02.Array-Sort/10.Array-Radix-Sort.md b/Contents/01.Array/02.Array-Sort/10.Array-Radix-Sort.md
index 2d80904c..9864d655 100644
--- a/Contents/01.Array/02.Array-Sort/10.Array-Radix-Sort.md
+++ b/Contents/01.Array/02.Array-Sort/10.Array-Radix-Sort.md
@@ -34,7 +34,7 @@
## 5. 基数排序代码实现
-```Python
+```python
class Solution:
def radixSort(self, arr):
# 桶的大小为所有元素的最大位数
diff --git a/Contents/01.Array/03.Array-Binary-Search/01.Array-Binary-Search.md b/Contents/01.Array/03.Array-Binary-Search/01.Array-Binary-Search.md
index f091ab2f..095aa052 100644
--- a/Contents/01.Array/03.Array-Binary-Search/01.Array-Binary-Search.md
+++ b/Contents/01.Array/03.Array-Binary-Search/01.Array-Binary-Search.md
@@ -50,7 +50,7 @@
**示例**:
-```Python
+```python
输入: nums = [-1,0,3,5,9,12], target = 9
输出: 4
解释: 9 出现在 nums 中并且下标为 4
@@ -75,7 +75,7 @@
#### 思路 1:代码
-```Python
+```python
class Solution:
def search(self, nums: List[int], target: int) -> int:
left, right = 0, len(nums) - 1
@@ -147,7 +147,7 @@ class Solution:
可以在返回的时候需要增加一层判断,判断 `left` 所指向位置是否等于目标元素,如果是的话就返回 `left`,如果不是的话返回 `-1`。即:
-````Python
+````python
# ...
while left < right:
# ...
@@ -187,7 +187,7 @@ class Solution:
#### 代码:
-```Python
+```python
class Solution:
def search(self, nums: List[int], target: int) -> int:
left, right = 0, len(nums) - 1
@@ -229,7 +229,7 @@ class Solution:
#### 第一种代码:
-```Python
+```python
class Solution:
def search(self, nums: List[int], target: int) -> int:
left, right = 0, len(nums) - 1
@@ -250,7 +250,7 @@ class Solution:
#### 第二种代码:
-```Python
+```python
class Solution:
def search(self, nums: List[int], target: int) -> int:
left, right = 0, len(nums) - 1
diff --git a/Contents/01.Array/04.Array-Two-Pointers/01.Array-Two-Pointers.md b/Contents/01.Array/04.Array-Two-Pointers/01.Array-Two-Pointers.md
index 1491c005..e38d6d58 100644
--- a/Contents/01.Array/04.Array-Two-Pointers/01.Array-Two-Pointers.md
+++ b/Contents/01.Array/04.Array-Two-Pointers/01.Array-Two-Pointers.md
@@ -16,7 +16,7 @@
### 2.2 对撞指针伪代码模板
-```Python
+```python
left, right = 0, len(nums) - 1
while left < right:
@@ -61,7 +61,7 @@ return 没找到 或 找到对应值
**示例**:
-```Python
+```python
输入:numbers = [2,7,11,15], target = 9
输出:[1,2]
解释:2 与 7 之和等于目标数 9 。因此 index1 = 1, index2 = 2 。返回 [1, 2] 。
@@ -76,7 +76,7 @@ return 没找到 或 找到对应值
这道题如果暴力遍历数组,从中找到相加之和等于 `target` 的两个数,时间复杂度为 $O(n^2)$,可以尝试一下。
-```Python
+```python
class Solution:
def twoSum(self, numbers: List[int], target: int) -> List[int]:
size = len(numbers)
@@ -103,7 +103,7 @@ class Solution:
##### 思路 1:代码
-```Python
+```python
class Solution:
def twoSum(self, numbers: List[int], target: int) -> List[int]:
left = 0
@@ -144,7 +144,7 @@ class Solution:
**示例**:
-```Python
+```python
输入: "A man, a plan, a canal: Panama"
输出:true
解释:"amanaplanacanalpanama" 是回文串。
@@ -168,7 +168,7 @@ class Solution:
##### 思路 1:代码
-```Python
+```python
class Solution:
def isPalindrome(self, s: str) -> bool:
left = 0
@@ -217,7 +217,7 @@ class Solution:

-```Python
+```python
输入:[1,8,6,2,5,4,8,3,7]
输出:49
解释:图中垂直线代表输入数组 [1,8,6,2,5,4,8,3,7]。在此情况下,容器能够容纳水(表示为蓝色部分)的最大值为 49。
@@ -240,7 +240,7 @@ class Solution:
##### 思路 1:代码
-```Python
+```python
class Solution:
def maxArea(self, height: List[int]) -> int:
left = 0
@@ -273,7 +273,7 @@ class Solution:
### 3.2 快慢指针伪代码模板
-```Python
+```python
slow = 0
fast = 1
while 没有遍历完:
@@ -307,7 +307,7 @@ return 合适的值
**示例**:
-```Python
+```python
输入:nums = [1,1,2]
输出:2, nums = [1,2,_]
解释:函数应该返回新的长度 2 ,并且原数组 nums 的前两个元素被修改为 1, 2 。不需要考虑数组中超出新长度后面的元素。
@@ -336,7 +336,7 @@ return 合适的值
##### 思路 1:代码
-```Python
+```python
class Solution:
def removeDuplicates(self, nums: List[int]) -> int:
if len(nums) <= 1:
@@ -372,7 +372,7 @@ class Solution:
### 4.2 分离双指针伪代码模板
-```Python
+```python
left_1 = 0
left_2 = 0
@@ -411,7 +411,7 @@ while left_1 < len(nums1) and left_2 < len(nums2):
**示例**:
-```Python
+```python
输入:nums1 = [1,2,2,1], nums2 = [2,2]
输出:[2]
示例 2:
@@ -434,7 +434,7 @@ while left_1 < len(nums1) and left_2 < len(nums2):
##### 思路 1:代码
-```Python
+```python
class Solution:
def intersection(self, nums1: List[int], nums2: List[int]) -> List[int]:
nums1.sort()
diff --git a/Contents/01.Array/05.Array-Sliding-Window/01.Array-Sliding-Window.md b/Contents/01.Array/05.Array-Sliding-Window/01.Array-Sliding-Window.md
index 375efb91..afcffb1d 100644
--- a/Contents/01.Array/05.Array-Sliding-Window/01.Array-Sliding-Window.md
+++ b/Contents/01.Array/05.Array-Sliding-Window/01.Array-Sliding-Window.md
@@ -39,7 +39,7 @@
### 3.2 固定长度窗口模板
-```Python
+```python
left = 0
right = 0
@@ -79,7 +79,7 @@ while right < len(nums):
**示例**:
-```Python
+```python
输入:arr = [2,2,2,2,5,5,5,8], k = 3, threshold = 4
输出:3
解释:子数组 [2,5,5],[5,5,5] 和 [5,5,8] 的平均值分别为 4,5 和 6 。其他长度为 3 的子数组的平均值都小于 4 (threshold 的值)。
@@ -107,7 +107,7 @@ while right < len(nums):
##### 思路 1:代码
-```Python
+```python
class Solution:
def numOfSubarrays(self, arr: List[int], k: int, threshold: int) -> int:
left = 0
@@ -147,7 +147,7 @@ class Solution:
### 4.2 不定长度窗口模板
-```Python
+```python
left = 0
right = 0
@@ -182,7 +182,7 @@ while right < len(nums):
**示例**:
-```Python
+```python
输入: s = "abcabcbb"
输出: 3
解释: 因为无重复字符的最长子串是 "abc",所以其长度为 3。
@@ -208,7 +208,7 @@ while right < len(nums):
##### 思路 1:代码
-```Python
+```python
class Solution:
def lengthOfLongestSubstring(self, s: str) -> int:
left = 0
@@ -257,7 +257,7 @@ class Solution:
**示例**:
-```Python
+```python
输入:target = 7, nums = [2,3,1,2,4,3]
输出:2
解释:子数组 [4,3] 是该条件下的长度最小的子数组。
@@ -283,7 +283,7 @@ class Solution:
##### 思路 1:代码
-```Python
+```python
class Solution:
def minSubArrayLen(self, target: int, nums: List[int]) -> int:
size = len(nums)
@@ -330,7 +330,7 @@ class Solution:
**示例**:
-```Python
+```python
输入:nums = [10,5,2,6], k = 100
输出:8
解释:8 个乘积小于 100 的子数组分别为:[10]、[5]、[2],、[6]、[10,5]、[5,2]、[2,6]、[5,2,6]。需要注意的是 [10,5,2] 并不是乘积小于 100 的子数组。
@@ -353,7 +353,7 @@ class Solution:
##### 思路 1:代码
-```Python
+```python
class Solution:
def numSubarrayProductLessThanK(self, nums: List[int], k: int) -> int:
if k <= 1:
diff --git a/Contents/02.Linked-List/01.Linked-List-Basic/01.Linked-List-Basic.md b/Contents/02.Linked-List/01.Linked-List-Basic/01.Linked-List-Basic.md
index 2739c542..19b96766 100644
--- a/Contents/02.Linked-List/01.Linked-List-Basic/01.Linked-List-Basic.md
+++ b/Contents/02.Linked-List/01.Linked-List-Basic/01.Linked-List-Basic.md
@@ -54,7 +54,7 @@
**「链节点以及链表的结构定义」** 代码如下:
-```Python
+```python
# 链节点类
class ListNode:
def __init__(self, val=0, next=None):
@@ -79,7 +79,7 @@ class LinkedList:
**「建立一个线性链表」** 的代码如下:
-```Python
+```python
# 根据 data 初始化一个新链表
def create(self, data):
self.head = ListNode(0)
@@ -102,7 +102,7 @@ def create(self, data):
**「求线性链表长度」** 的代码如下:
-```Python
+```python
# 获取链表长度
def length(self):
count = 0
@@ -121,7 +121,7 @@ def length(self):
**「在链表中查找元素」** 的代码如下:
-```Python
+```python
# 查找元素
def find(self, val):
cur = self.head
@@ -157,7 +157,7 @@ def find(self, val):
**「在链表头部插入值为 `val` 元素」** 的代码如下:
-```Python
+```python
# 头部插入元素
def insertFront(self, val):
node = ListNode(val)
@@ -180,7 +180,7 @@ def insertFront(self, val):
**「在链表尾部插入值为 `val` 的元素」** 的代码如下:
-```Python
+```python
# 尾部插入元素
def insertRear(self, val):
node = ListNode(val)
@@ -207,7 +207,7 @@ def insertRear(self, val):
**「在链表第 `i` 个链节点之前插入值为 `val` 的元素」** 的代码如下:
-```Python
+```python
# 中间插入元素
def insertInside(self, index, val):
count = 0
@@ -237,7 +237,7 @@ def insertInside(self, index, val):
**「将链表中第 `i` 个元素值改为 `val`」** 的代码如下:
-```Python
+```python
# 改变元素
def change(self, index, val):
count = 0
@@ -274,7 +274,7 @@ def change(self, index, val):
**「链表头部删除元素」** 的代码如下所示:
-```Python
+```python
# 链表头部删除元素
def removeFront(self):
if self.head:
@@ -294,7 +294,7 @@ def removeFront(self):
**「链表尾部删除元素」** 的代码如下所示:
-```Python
+```python
# 链表尾部删除元素
def removeRear(self):
if not self.head.next:
@@ -317,7 +317,7 @@ def removeRear(self):
**「删除链表中第 `i` 个元素」** 的代码如下所示:
-```Python
+```python
# 链表中间删除元素
def removeInside(self, index):
count = 0
diff --git a/Contents/02.Linked-List/02.Linked-List-Sort/01.Linked-List-Sort.md b/Contents/02.Linked-List/02.Linked-List-Sort/01.Linked-List-Sort.md
index 4d6b233e..169dcfd9 100644
--- a/Contents/02.Linked-List/02.Linked-List-Sort/01.Linked-List-Sort.md
+++ b/Contents/02.Linked-List/02.Linked-List-Sort/01.Linked-List-Sort.md
@@ -46,7 +46,7 @@
### 2.2 链表冒泡排序算法实现代码
-```Python
+```python
class Solution:
def bubbleSort(self, head: ListNode):
node_i = head
@@ -88,7 +88,7 @@ class Solution:
### 3.2 链表选择排序实现代码
-```Python
+```python
class Solution:
def sectionSort(self, head: ListNode):
node_i = head
@@ -134,7 +134,7 @@ class Solution:
### 4.2 链表插入排序实现代码
-```Python
+```python
class Solution:
def insertionSort(self, head: ListNode):
if not head or not head.next:
@@ -187,7 +187,7 @@ class Solution:
### 5.2 链表归并排序实现代码
-```Python
+```python
class Solution:
def merge(self, left, right):
# 归并环节
@@ -246,7 +246,7 @@ class Solution:
### 6.2 链表快速排序实现代码
-```Python
+```python
class Solution:
def partition(self, left: ListNode, right: ListNode):
# 左闭右开,区间没有元素或者只有一个元素,直接返回第一个节点
@@ -302,7 +302,7 @@ class Solution:
### 7.2 链表计数排序代码实现
-```Python
+```python
class Solution:
def countingSort(self, head: ListNode):
if not head:
@@ -357,7 +357,7 @@ class Solution:
### 8.2 链表桶排序代码实现
-```Python
+```python
class ListNode:
def __init__(self, val=0, next=None):
self.val = val
@@ -472,7 +472,7 @@ class Solution:
### 9.2 链表基数排序代码实现
-```Python
+```python
class Solution:
def radixSort(self, head: ListNode):
# 计算位数最长的位数
diff --git a/Contents/02.Linked-List/03.Linked-List-Two-Pointers/01.Linked-List-Two-Pointers.md b/Contents/02.Linked-List/03.Linked-List-Two-Pointers/01.Linked-List-Two-Pointers.md
index 154a4676..95028f79 100644
--- a/Contents/02.Linked-List/03.Linked-List-Two-Pointers/01.Linked-List-Two-Pointers.md
+++ b/Contents/02.Linked-List/03.Linked-List-Two-Pointers/01.Linked-List-Two-Pointers.md
@@ -18,7 +18,7 @@
### 2.2 起点不一致的快慢指针伪代码模板
-```Python
+```python
slow = head
fast = head
@@ -58,7 +58,7 @@ while fast:

-```Python
+```python
输入:head = [1,2,3,4,5], n = 2
输出:[1,2,3,5]
@@ -79,7 +79,7 @@ while fast:
##### 思路 1:代码
-```Python
+```python
class Solution:
def removeNthFromEnd(self, head: ListNode, n: int) -> ListNode:
newHead = ListNode(0, head)
@@ -112,7 +112,7 @@ class Solution:
### 3.2 步长不一致的快慢指针伪代码模板
-```Python
+```python
fast = head
slow = head
@@ -143,7 +143,7 @@ while fast and fast.next:
**示例**:
-```Python
+```python
输入:[1,2,3,4,5]
输出:此列表中的结点 3 (序列化形式:[3,4,5])
解释:返回的结点值为 3 。
@@ -164,7 +164,7 @@ ans.val = 3, ans.next.val = 4, ans.next.next.val = 5, 以及 ans.next.next.next
##### 思路 1:代码
-```Python
+```python
class Solution:
def middleNode(self, head: ListNode) -> ListNode:
n = 0
@@ -196,7 +196,7 @@ class Solution:
##### 思路 2:代码
-```Python
+```python
class Solution:
def middleNode(self, head: ListNode) -> ListNode:
fast = head
@@ -234,7 +234,7 @@ class Solution:

-```Python
+```python
输入:head = [3,2,0,-4], pos = 1
输出:True
解释:链表中有一个环,其尾部连接到第二个节点。
@@ -242,7 +242,7 @@ class Solution:

-```Python
+```python
输入:head = [1,2], pos = 0
输出:True
解释:链表中有一个环,其尾部连接到第一个节点。
@@ -256,7 +256,7 @@ class Solution:
##### 思路 1:代码
-```Python
+```python
class Solution:
def hasCycle(self, head: ListNode) -> bool:
nodeset = set()
@@ -282,7 +282,7 @@ class Solution:
##### 思路 2:代码
-```Python
+```python
class Solution:
def hasCycle(self, head: ListNode) -> bool:
if head == None or head.next == None:
@@ -319,7 +319,7 @@ class Solution:
### 4.2 分离双指针伪代码模板
-```Python
+```python
left_1 = list1
left_2 = list2
@@ -359,7 +359,7 @@ while left_1 and left_2:

-```Python
+```python
输入:list1 = [1,2,4], list2 = [1,3,4]
输出:[1,1,2,3,4,4]
@@ -382,7 +382,7 @@ while left_1 and left_2:
##### 思路 1:代码
-```Python
+```python
class Solution:
def mergeTwoLists(self, list1: Optional[ListNode], list2: Optional[ListNode]) -> Optional[ListNode]:
dummy_head = ListNode(-1)
diff --git a/Contents/03.Stack/01.Stack-Basic/01.Stack-Basic.md b/Contents/03.Stack/01.Stack-Basic/01.Stack-Basic.md
index 8c1b6e9c..f7b7f95e 100644
--- a/Contents/03.Stack/01.Stack-Basic/01.Stack-Basic.md
+++ b/Contents/03.Stack/01.Stack-Basic/01.Stack-Basic.md
@@ -70,7 +70,7 @@
#### 2.2.2 堆栈的顺序存储实现代码
-```Python
+```python
class Stack:
# 初始化空栈
def __init__(self, size=100):
@@ -128,7 +128,7 @@ class Stack:
#### 2.3.2 堆栈的链式存储实现代码
-```Python
+```python
class Node:
def __init__(self, value):
self.value = value
@@ -197,7 +197,7 @@ class Stack:
**示例**:
-```Python
+```python
输入:s = "()"
输出:True
@@ -224,7 +224,7 @@ class Stack:
##### 思路 1:代码
-```Python
+```python
class Solution:
def isValid(self, s: str) -> bool:
if len(s) % 2 == 1:
@@ -281,7 +281,7 @@ class Solution:
**示例**:
-```Python
+```python
输入:s = "3+2*2"
输出:7
@@ -311,7 +311,7 @@ class Solution:
##### 思路 1:代码
-```Python
+```python
class Solution:
def calculate(self, s: str) -> int:
size = len(s)
diff --git a/Contents/03.Stack/02.Monotone-Stack/01.Monotone-Stack.md b/Contents/03.Stack/02.Monotone-Stack/01.Monotone-Stack.md
index c3b33c47..fbc70c07 100644
--- a/Contents/03.Stack/02.Monotone-Stack/01.Monotone-Stack.md
+++ b/Contents/03.Stack/02.Monotone-Stack/01.Monotone-Stack.md
@@ -131,7 +131,7 @@
### 3.1 单调递增栈模板
-```Python
+```python
def monotoneIncreasingStack(nums):
stack = []
for num in nums:
@@ -142,7 +142,7 @@ def monotoneIncreasingStack(nums):
### 3.2 单调递减栈模板
-```Python
+```python
def monotoneDecreasingStack(nums):
stack = []
for num in nums:
@@ -185,7 +185,7 @@ def monotoneDecreasingStack(nums):
#### 4.1.4 代码
-```Python
+```python
class Solution:
def nextGreaterElement(self, nums1: List[int], nums2: List[int]) -> List[int]:
res = []
@@ -221,7 +221,7 @@ class Solution:
**示例**:
-```Python
+```python
输入: temperatures = [73,74,75,71,69,72,76,73]
输出: [1,1,4,2,1,1,0,0]
@@ -249,7 +249,7 @@ class Solution:
##### 思路 1:代码
-```Python
+```python
class Solution:
def dailyTemperatures(self, T: List[int]) -> List[int]:
n = len(T)
diff --git a/Contents/04.Queue/01.Queue-Basic/01.Queue-Basic.md b/Contents/04.Queue/01.Queue-Basic/01.Queue-Basic.md
index 401ecb67..13eb3d55 100644
--- a/Contents/04.Queue/01.Queue-Basic/01.Queue-Basic.md
+++ b/Contents/04.Queue/01.Queue-Basic/01.Queue-Basic.md
@@ -70,7 +70,7 @@
#### 2.2.2 队列的顺序存储实现代码
-```Python
+```python
class Queue:
# 初始化空队列
def __init__(self, size=100):
@@ -130,7 +130,7 @@ class Queue:
- 第一种:每一次删除队头元素之后,就将整个队列往前移动 `1` 个位置。其代码如下所示:
-```Python
+```python
# 出队操作
def dequeue(self):
if self.is_empty():
@@ -190,7 +190,7 @@ def dequeue(self):
#### 2.3.2 循环队列的顺序存储实现代码
-```Python
+```python
class Queue:
# 初始化空队列
def __init__(self, size=100):
@@ -266,7 +266,7 @@ class Queue:
#### 2.3.2 队列的链式存储实现代码
-```Python
+```python
class Node:
def __init__(self, value):
self.value = value
diff --git a/Contents/04.Queue/02.Priority-Queue/01.Priority-Queue.md b/Contents/04.Queue/02.Priority-Queue/01.Priority-Queue.md
index f191b543..9f029adc 100644
--- a/Contents/04.Queue/02.Priority-Queue/01.Priority-Queue.md
+++ b/Contents/04.Queue/02.Priority-Queue/01.Priority-Queue.md
@@ -96,7 +96,7 @@
- `heappop`:删除堆顶元素,也是优先队列的出队操作,弹出优先队列中优先级最高的元素。
- `heapSort`:堆排序。
-```Python
+```python
class Heapq:
# 堆调整方法:调整为大顶堆
def heapAdjust(self, nums: [int], index: int, end: int):
@@ -170,7 +170,7 @@ Python 中的 `heapq` 模块提供了优先队列算法。函数 `heapq.heappush
需要注意的是:`heapq.heappop()` 函数总是返回「最小的」的元素。所以我们在使用 `heapq.heappush()` 时,将优先级设置为负数,这样就使得元素可以按照优先级从高到低排序, 这个跟普通的按优先级从低到高排序的堆排序恰巧相反。这样做的目的是为了 `heapq.heappop()` 每次弹出的元素都是优先级最高的元素。
-```Python
+```python
import heapq
class PriorityQueue:
@@ -208,7 +208,7 @@ class PriorityQueue:
**示例**:
-```Python
+```python
输入:nums = [1,3,-1,-3,5,3,6,7], k = 3
输出:[3,3,5,5,6,7]
解释:
@@ -242,7 +242,7 @@ class PriorityQueue:
##### 思路 1:代码
-```Python
+```python
class Solution:
def maxSlidingWindow(self, nums: List[int], k: int) -> List[int]:
size = len(nums)
@@ -283,7 +283,7 @@ class Solution:
**示例**:
-```Python
+```python
输入: nums = [1,1,1,2,2,3], k = 2
输出: [1,2]
@@ -305,7 +305,7 @@ class Solution:
##### 思路 1:代码
-```Python
+```python
class Heapq:
# 堆调整方法:调整为大顶堆
def heapAdjust(self, nums: [int], nums_dict, index: int, end: int):
diff --git a/Contents/06.String/01.String-Basic/01.String-Basic.md b/Contents/06.String/01.String-Basic/01.String-Basic.md
index f08a5f1e..e6b41e75 100644
--- a/Contents/06.String/01.String-Basic/01.String-Basic.md
+++ b/Contents/06.String/01.String-Basic/01.String-Basic.md
@@ -14,7 +14,7 @@
举个例子来说明一下:
-```Python
+```python
str = "Hello World"
```
@@ -76,7 +76,7 @@ str = "Hello World"
`strcmp` 方法对应的具体代码如下:
-```Python
+```python
def strcmp(str1, str2):
index1, index2 = 0, 0
while index1 < len(str1) and index2 < len(str2):
diff --git a/Contents/06.String/02.String-Single-Pattern-Matching/01.String-Brute-Force.md b/Contents/06.String/02.String-Single-Pattern-Matching/01.String-Brute-Force.md
index c266f10a..8e97897b 100644
--- a/Contents/06.String/02.String-Single-Pattern-Matching/01.String-Brute-Force.md
+++ b/Contents/06.String/02.String-Single-Pattern-Matching/01.String-Brute-Force.md
@@ -16,7 +16,7 @@
## 3. Brute Force 算法代码实现
-```Python
+```python
def bruteForce(T: str, p: str) -> int:
n, m = len(T), len(p)
diff --git a/Contents/06.String/02.String-Single-Pattern-Matching/02.String-Rabin-Karp.md b/Contents/06.String/02.String-Single-Pattern-Matching/02.String-Rabin-Karp.md
index 539dfb99..3f602667 100644
--- a/Contents/06.String/02.String-Single-Pattern-Matching/02.String-Rabin-Karp.md
+++ b/Contents/06.String/02.String-Single-Pattern-Matching/02.String-Rabin-Karp.md
@@ -58,7 +58,7 @@ $\begin{align} Hash(ate) &= (Hash(cat) - c \times 26 \times 26) * 26 + e \times
## 3. Rabin Karp 算法代码实现
-```Python
+```python
# T 为文本串,p 为模式串,d 为字符集的字符种类数,q 为质数
def rabinKarp(T: str, p: str, d, q) -> int:
n, m = len(T), len(p)
diff --git a/Contents/06.String/02.String-Single-Pattern-Matching/03.String-KMP.md b/Contents/06.String/02.String-Single-Pattern-Matching/03.String-KMP.md
index a052f372..7e4b1a14 100644
--- a/Contents/06.String/02.String-Single-Pattern-Matching/03.String-KMP.md
+++ b/Contents/06.String/02.String-Single-Pattern-Matching/03.String-KMP.md
@@ -98,7 +98,7 @@ KMP 算法就是使用了这样的思路,对模式串 `p` 进行了预处理
## 3. KMP 算法代码实现
-```Python
+```python
# 生成 next 数组
# next[j] 表示下标 j 之前的模式串 p 中,最长相等前后缀的长度
def generateNext(p: str):
diff --git a/Contents/06.String/02.String-Single-Pattern-Matching/04.String-Boyer-Moore.md b/Contents/06.String/02.String-Single-Pattern-Matching/04.String-Boyer-Moore.md
index 80224248..dc54e5f2 100644
--- a/Contents/06.String/02.String-Single-Pattern-Matching/04.String-Boyer-Moore.md
+++ b/Contents/06.String/02.String-Single-Pattern-Matching/04.String-Boyer-Moore.md
@@ -145,7 +145,7 @@ BM 算法的匹配过程实现起来并不是很难,而整个算法实现的
生成坏字符位置表的代码如下:
-```Python
+```python
# 生成坏字符位置表
# bc_table[bad_char] 表示坏字符在模式串中最后一次出现的位置
def generateBadCharTable(p: str):
@@ -162,7 +162,7 @@ def generateBadCharTable(p: str):
构建 `suffix` 数组的代码如下:
-```Python
+```python
# 生成 suffix 数组
# suffix[i] 表示为以下标 i 为结尾的子串与模式串后缀匹配的最大长度
def generageSuffixArray(p: str):
@@ -192,7 +192,7 @@ def generageSuffixArray(p: str):
生成好后缀规则后移位数表 `gs_list` 代码如下:
-```Python
+```python
# 生成好后缀规则后移位数表
# gs_list[j] 表示在 j 下标处遇到坏字符时,可根据好规则向右移动的距离
def generageGoodSuffixList(p: str):
@@ -220,7 +220,7 @@ def generageGoodSuffixList(p: str):
### 5.3 Boyer Moore 算法整体代码实现
-```Python
+```python
# BM 匹配算法
def boyerMoore(T: str, p: str) -> int:
n, m = len(T), len(p)
diff --git a/Contents/06.String/02.String-Single-Pattern-Matching/05.String-Horspool.md b/Contents/06.String/02.String-Single-Pattern-Matching/05.String-Horspool.md
index e4745452..be831fc1 100644
--- a/Contents/06.String/02.String-Single-Pattern-Matching/05.String-Horspool.md
+++ b/Contents/06.String/02.String-Single-Pattern-Matching/05.String-Horspool.md
@@ -47,7 +47,7 @@
生成后移位数表的代码如下:
-```Python
+```python
# 生成后移位数表
# bc_table[bad_char] 表示遇到坏字符可以向右移动的距离
def generateBadCharTable(p: str):
@@ -61,7 +61,7 @@ def generateBadCharTable(p: str):
### 3.2 Horspool 算法整体代码实现
-```Python
+```python
# horspool 算法,T 为文本串,p 为模式串
def horspool(T: str, p: str) -> int:
n, m = len(T), len(p)
diff --git a/Contents/06.String/02.String-Single-Pattern-Matching/06.String-Sunday.md b/Contents/06.String/02.String-Single-Pattern-Matching/06.String-Sunday.md
index 5f0f4d22..1b37ef55 100644
--- a/Contents/06.String/02.String-Single-Pattern-Matching/06.String-Sunday.md
+++ b/Contents/06.String/02.String-Single-Pattern-Matching/06.String-Sunday.md
@@ -47,7 +47,7 @@ Sunday 算法思想跟 Boyer Moore 算法思想类似。不同的是,Sunday
生成后移位数表的代码如下:
-```Python
+```python
# 生成后移位数表
# bc_table[bad_char] 表示遇到坏字符可以向右移动的距离
def generateBadCharTable(p: str):
@@ -61,7 +61,7 @@ def generateBadCharTable(p: str):
### 3.2 Sunday 算法整体代码实现
-```Python
+```python
# sunday 算法,T 为文本串,p 为模式串
def sunday(T: str, p: str) -> int:
n, m = len(T), len(p)
diff --git a/Contents/06.String/03.String-Multi-Pattern-Matching/01.Trie.md b/Contents/06.String/03.String-Multi-Pattern-Matching/01.Trie.md
index 4ae97ce4..33abd869 100644
--- a/Contents/06.String/03.String-Multi-Pattern-Matching/01.Trie.md
+++ b/Contents/06.String/03.String-Multi-Pattern-Matching/01.Trie.md
@@ -32,7 +32,7 @@
- 如果字符串所涉及的字符集合只包含小写英文字母的话,我们可以使用一个长度为 `26` 的数组来表示当前节点的多个子节点,如下面代码所示。
-```Python
+```python
class Node: # 字符节点
def __init__(self): # 初始化字符节点
self.children = [None for _ in range(26)] # 初始化子节点
@@ -45,7 +45,7 @@ class Node: # 字符节点
- 如果所涉及的字符集合不仅包含小写字母,还包含大写字母和其他字符,我们可以使用哈希表来表示当前节点的多个子节点,如下面代码所示。
-```Python
+```python
class Node: # 字符节点
def __init__(self): # 初始化字符节点
self.children = dict() # 初始化子节点
@@ -60,7 +60,7 @@ class Node: # 字符节点
定义完了字典树的字符结构,下面我们定义下字典树的基本结构。在字典树的初始化操作时,定义一个根节点。并且这个根节点不用保存字符。在后续进行插入操作、查找操作都是从字典树的根节点开始的。字典树的基本结构代码如下。
-```Python
+```python
class Trie: # 字典树
# 初始化字典树
@@ -81,7 +81,7 @@ class Trie: # 字典树
- 如果当前节点的子节点中,存在键为 `ch` 的节点,则直接令当前节点指向键为 `ch` 的节点,继续处理下一个字符。
- 在单词处理完成时,将当前节点标记为单词结束。
-```Python
+```python
# 向字典树中插入一个单词
def insert(self, word: str) -> None:
cur = self.root
@@ -99,7 +99,7 @@ def insert(self, word: str) -> None:
- 首先初始化一个字典树,即 `trie = Trie()`。
- 然后依次遍历字符串中的所有单词,将其一一插入到字典树中。
-```Python
+```python
trie = Trie()
for word in words:
trie.insert(word)
@@ -116,7 +116,7 @@ for word in words:
- 如果当前节点的子节点中,存在键为 `ch` 的节点,则令当前节点指向新建立的节点,然后继续查找下一个字符。
- 在单词处理完成时,判断当前节点是否有单词结束标记,如果有,则说明字典树中存在该单词,返回 `True`。否则,则说明字典树中不存在该单词,返回 `False`。
-```Python
+```python
# 查找字典树中是否存在一个单词
def search(self, word: str) -> bool:
cur = self.root
@@ -132,7 +132,7 @@ def search(self, word: str) -> bool:
在字典树中查找某个前缀是否存在,和字典树的查找单词操作一样,不同点在于最后不需要判断是否有单词结束标记。
-```Python
+```python
# 查找字典树中是否存在一个前缀
def startsWith(self, prefix: str) -> bool:
cur = self.root
@@ -145,7 +145,7 @@ def startsWith(self, prefix: str) -> bool:
## 3. 字典树的实现代码
-```Python
+```python
class Node: # 字符节点
def __init__(self): # 初始化字符节点
self.children = dict() # 初始化子节点
diff --git a/Contents/07.Tree/01.Binary-Tree/01.Binary-Tree-Basic.md b/Contents/07.Tree/01.Binary-Tree/01.Binary-Tree-Basic.md
index b6074201..d835a012 100644
--- a/Contents/07.Tree/01.Binary-Tree/01.Binary-Tree-Basic.md
+++ b/Contents/07.Tree/01.Binary-Tree/01.Binary-Tree-Basic.md
@@ -184,7 +184,7 @@
二叉链节点结构的对应代码为:
-```Python
+```python
class TreeNode:
def __init__(self, val=0, left=None, right=None):
self.val = val
diff --git a/Contents/07.Tree/01.Binary-Tree/02.Binary-Tree-Traverse.md b/Contents/07.Tree/01.Binary-Tree/02.Binary-Tree-Traverse.md
index 20e9964b..2917f01d 100644
--- a/Contents/07.Tree/01.Binary-Tree/02.Binary-Tree-Traverse.md
+++ b/Contents/07.Tree/01.Binary-Tree/02.Binary-Tree-Traverse.md
@@ -37,7 +37,7 @@
二叉树的前序遍历递归实现代码如下:
-```Python
+```python
class Solution:
def preorderTraversal(self, root: TreeNode) -> List[int]:
res = []
@@ -70,7 +70,7 @@ class Solution:
二叉树的前序遍历显式栈实现代码如下:
-```Python
+```python
class Solution:
def preorderTraversal(self, root: Optional[TreeNode]) -> List[int]:
if not root: # 二叉树为空直接返回
@@ -117,7 +117,7 @@ class Solution:
二叉树的中序遍历递归实现代码如下:
-```Python
+```python
class Solution:
def inorderTraversal(self, root: TreeNode) -> List[int]:
res = []
@@ -152,7 +152,7 @@ class Solution:
二叉树的中序遍历显式栈实现代码如下:
-```Python
+```python
class Solution:
def inorderTraversal(self, root: Optional[TreeNode]) -> List[int]:
if not root: # 二叉树为空直接返回
@@ -199,7 +199,7 @@ class Solution:
二叉树的后序遍历递归实现代码如下:
-```Python
+```python
class Solution:
def postorderTraversal(self, root: TreeNode) -> List[int]:
res = []
@@ -232,7 +232,7 @@ class Solution:
2. 如果栈顶元素 `node` 无右子树(即 `not node.right`)或者右子树已经访问完毕(即 `node.right == prev`),则访问该元素,然后记录前一节点,并将当前节点标记为空节点。
2. 如果栈顶元素有右子树,则将栈顶元素重新压入栈中,继续访问栈顶元素的右子树。
-```Python
+```python
class Solution:
def postorderTraversal(self, root: Optional[TreeNode]) -> List[int]:
res = []
@@ -285,7 +285,7 @@ class Solution:
二叉树的层序遍历代码实现如下:
-```Python
+```python
class Solution:
def levelOrder(self, root: TreeNode) -> List[List[int]]:
if not root:
diff --git a/Contents/07.Tree/01.Binary-Tree/04.Binary-Tree-Reduction.md b/Contents/07.Tree/01.Binary-Tree/04.Binary-Tree-Reduction.md
index dfa35055..36f8b1df 100644
--- a/Contents/07.Tree/01.Binary-Tree/04.Binary-Tree-Reduction.md
+++ b/Contents/07.Tree/01.Binary-Tree/04.Binary-Tree-Reduction.md
@@ -64,7 +64,7 @@
### 2.2 从前序与中序遍历序列构造二叉树实现代码
-```Python
+```python
class Solution:
def buildTree(self, preorder: List[int], inorder: List[int]) -> TreeNode:
def createTree(preorder, inorder, n):
@@ -101,7 +101,7 @@ class Solution:
### 3.2 从中序与后序遍历序列构造二叉树实现代码
-```Python
+```python
class Solution:
def buildTree(self, inorder: List[int], postorder: List[int]) -> TreeNode:
def createTree(inorder, postorder, n):
@@ -141,7 +141,7 @@ class Solution:
### 4.2 从前序与后序遍历序列构造二叉树实现代码
-```Python
+```python
class Solution:
def constructFromPrePost(self, preorder: List[int], postorder: List[int]) -> TreeNode:
def createTree(preorder, postorder, n):
diff --git a/Contents/07.Tree/02.Binary-Search-Tree/01.Binary-Search-Tree.md b/Contents/07.Tree/02.Binary-Search-Tree/01.Binary-Search-Tree.md
index 455a4dd3..3aa7a3ec 100644
--- a/Contents/07.Tree/02.Binary-Search-Tree/01.Binary-Search-Tree.md
+++ b/Contents/07.Tree/02.Binary-Search-Tree/01.Binary-Search-Tree.md
@@ -30,7 +30,7 @@
### 2.2 二叉搜索树的查找代码实现
-```Python
+```python
class TreeNode:
def __init__(self, val=0, left=None, right=None):
self.val = val
@@ -72,7 +72,7 @@ class Solution:
### 3.2 二叉搜索树的插入代码实现
-```Python
+```python
class TreeNode:
def __init__(self, val=0, left=None, right=None):
self.val = val
@@ -105,7 +105,7 @@ class Solution:
### 4.2 二叉搜索树的创建代码实现
-```Python
+```python
class TreeNode:
def __init__(self, val=0, left=None, right=None):
self.val = val
@@ -156,7 +156,7 @@ class Solution:
### 5.2 二叉搜索树的删除代码实现
-```Python
+```python
class TreeNode:
def __init__(self, val=0, left=None, right=None):
self.val = val
diff --git a/Contents/07.Tree/03.Segment-Tree/01.Segment-Tree.md b/Contents/07.Tree/03.Segment-Tree/01.Segment-Tree.md
index 218cd283..368f40bb 100644
--- a/Contents/07.Tree/03.Segment-Tree/01.Segment-Tree.md
+++ b/Contents/07.Tree/03.Segment-Tree/01.Segment-Tree.md
@@ -50,7 +50,7 @@
线段树的构建实现代码如下:
-```Python
+```python
# 线段树的节点类
class TreeNode:
def __init__(self, val=0):
@@ -111,7 +111,7 @@ class SegmentTree:
线段树的单点更新实现代码如下:
-```Python
+```python
# 单点更新,将 nums[i] 更改为 val
def update_point(self, i, val):
self.nums[i] = val
@@ -148,7 +148,7 @@ class SegmentTree:
线段树的区间查询代码如下:
-```Python
+```python
# 区间查询,查询区间为 [q_left, q_right] 的区间值
def query_interval(self, q_left, q_right):
return self.__query_interval(q_left, q_right, 0, 0, self.size - 1)
@@ -210,7 +210,7 @@ class SegmentTree:
使用「延迟标记」的区间更新实现代码如下:
-```Python
+```python
# 区间更新,将区间为 [q_left, q_right] 上的元素值修改为 val
def update_interval(self, q_left, q_right, val):
self.__update_interval(q_left, q_right, val, 0, 0, self.size - 1)
@@ -264,7 +264,7 @@ class SegmentTree:
使用「延迟标记」的区间增减更新实现代码如下:
-```Python
+```python
# 区间更新,将区间为 [q_left, q_right] 上的元素值修改为 val
def update_interval(self, q_left, q_right, val):
self.__update_interval(q_left, q_right, val, 0, 0, self.size - 1)
@@ -385,7 +385,7 @@ class SegmentTree:
动态开点线段树实现代码如下:
-```Python
+```python
# 线段树的节点类
class TreeNode:
def __init__(self, left=-1, right=-1, val=0):
diff --git a/Contents/07.Tree/05.Union-Find/01.Union-Find.md b/Contents/07.Tree/05.Union-Find/01.Union-Find.md
index ae246d34..1939baa0 100644
--- a/Contents/07.Tree/05.Union-Find/01.Union-Find.md
+++ b/Contents/07.Tree/05.Union-Find/01.Union-Find.md
@@ -14,7 +14,7 @@
- 并查集中的「集」指的就是我们初中所学的集合概念,在这里指的是不相交的集合,即一系列没有重复元素的集合。
- 并查集中的「并」指的就是集合的并集操作,将两个集合合并之后就变成一个集合。合并操作如下所示:
-```Python
+```python
{1, 3, 5, 7} ∪ {2, 4, 6, 8} = {1, 2, 3, 4, 5, 6, 7, 8}
```
@@ -54,7 +54,7 @@
- 使用「快速查询」思路实现并查集代码如下所示:
-```Python
+```python
class UnionFind:
def __init__(self, n): # 初始化:将每个元素的集合编号初始化为数组下标索引
self.ids = [i for i in range(n)]
@@ -106,7 +106,7 @@ class UnionFind:
- 使用「快速合并」思路实现并查集代码如下所示:
-```Python
+```python
class UnionFind:
def __init__(self, n): # 初始化:将每个元素的集合编号初始化为数组 fa 的下标索引
self.fa = [i for i in range(n)]
@@ -150,7 +150,7 @@ class UnionFind:
- 隔代压缩的查找代码如下:
-```Python
+```python
def find(self, x): # 查找元素根节点的集合编号内部实现方法
while self.fa[x] != x: # 递归查找元素的父节点,直到根节点
self.fa[x] = self.fa[self.fa[x]] # 隔代压缩
@@ -168,7 +168,7 @@ def find(self, x): # 查找元素根节点的集合
- 完全压缩的查找代码如下:
-```Python
+```python
def find(self, x): # 查找元素根节点的集合编号内部实现方法
if self.fa[x] != x: # 递归查找元素的父节点,直到根节点
self.fa[x] = self.find(self.fa[x]) # 完全压缩优化
@@ -199,7 +199,7 @@ def find(self, x): # 查找元素根节点的集合
- 按深度合并的实现代码如下:
-```Python
+```python
class UnionFind:
def __init__(self, n): # 初始化
self.fa = [i for i in range(n)] # 每个元素的集合编号初始化为数组 fa 的下标索引
@@ -244,7 +244,7 @@ class UnionFind:
- 按大小合并的实现代码如下:
-```Python
+```python
class UnionFind:
def __init__(self, n): # 初始化
self.fa = [i for i in range(n)] # 每个元素的集合编号初始化为数组 fa 的下标索引
@@ -311,7 +311,7 @@ class UnionFind:
- 使用「隔代压缩」,不使用「按秩合并」的并查集最终实现代码:
-```Python
+```python
class UnionFind:
def __init__(self, n): # 初始化
self.fa = [i for i in range(n)] # 每个元素的集合编号初始化为数组 fa 的下标索引
@@ -337,7 +337,7 @@ class UnionFind:
- 使用「隔代压缩」,使用「按秩合并」的并查集最终实现代码:
-```Python
+```python
class UnionFind:
def __init__(self, n): # 初始化
self.fa = [i for i in range(n)] # 每个元素的集合编号初始化为数组 fa 的下标索引
@@ -394,7 +394,7 @@ class UnionFind:
**示例**:
-```Python
+```python
输入 ["a==b","b!=a"]
输出 False
解释 如果我们指定,a = 1 且 b = 1,那么可以满足第一个方程,但无法满足第二个方程。没有办法分配变量同时满足这两个方程。
@@ -411,7 +411,7 @@ class UnionFind:
#### 6.1.4 代码
-```Python
+```python
class UnionFind:
def __init__(self, n): # 初始化
self.fa = [i for i in range(n)] # 每个元素的集合编号初始化为数组 fa 的下标索引
@@ -483,7 +483,7 @@ class Solution:

-```Python
+```python
输入 isConnected = [[1,1,0],[1,1,0],[0,0,1]]
输出 2
```
@@ -496,7 +496,7 @@ class Solution:
#### 6.2.4 代码
-```Python
+```python
class UnionFind:
def __init__(self, n): # 初始化
self.fa = [i for i in range(n)] # 每个元素的集合编号初始化为数组 fa 的下标索引
diff --git a/Contents/08.Graph/01.Graph-Basic/02.Graph-Structure.md b/Contents/08.Graph/01.Graph-Basic/02.Graph-Structure.md
index 15ea78ed..eae79179 100644
--- a/Contents/08.Graph/01.Graph-Basic/02.Graph-Structure.md
+++ b/Contents/08.Graph/01.Graph-Basic/02.Graph-Structure.md
@@ -39,7 +39,7 @@
#### 1.1.3 邻接矩阵的代码实现
-```Python
+```python
class Graph: # 基本图类,采用邻接矩阵表示
# 图的初始化操作,ver_count 为顶点个数
def __init__(self, ver_count):
@@ -114,7 +114,7 @@ graph.printGraph()
#### 1.2.3 边集数组的代码实现
-```Python
+```python
class EdgeNode: # 边信息类
def __init__(self, vi, vj, val):
self.vi = vi # 边的起点
@@ -186,7 +186,7 @@ graph.printGraph()
#### 1.3.3 邻接表的代码实现
-```Python
+```python
class EdgeNode: # 边信息类
def __init__(self, vj, val):
self.vj = vj # 边的终点
@@ -293,7 +293,7 @@ graph.printGraph()
#### 1.4.3 链式前向星的代码实现
-```Python
+```python
class EdgeNode: # 边信息类
def __init__(self, vj, val):
self.vj = vj # 边的终点
@@ -377,7 +377,7 @@ graph.printGraph()
#### 1.5.3 哈希表实现邻接表的代码实现
-```Python
+```python
class VertexNode: # 顶点信息类
def __init__(self, vi):
self.vi = vi # 顶点
diff --git a/Contents/08.Graph/02.Graph-Traversal/01.Graph-DFS.md b/Contents/08.Graph/02.Graph-Traversal/01.Graph-DFS.md
index 7e0720d7..9e061c2f 100644
--- a/Contents/08.Graph/02.Graph-Traversal/01.Graph-DFS.md
+++ b/Contents/08.Graph/02.Graph-Traversal/01.Graph-DFS.md
@@ -14,7 +14,7 @@
我们用邻接字典的方式存储无向图结构,对应结构如下:
-```Python
+```python
# 定义无向图结构
graph = {
"A": ["B", "C"],
@@ -48,7 +48,7 @@ graph = {
### 3.2 基于递归实现的深度优先搜索实现代码
-```Python
+```python
def dfs_recursive(graph, start, visited):
# 标记节点
visited.add(start)
@@ -80,7 +80,7 @@ def dfs_recursive(graph, start, visited):
### 4.2 基于堆栈实现的深度优先搜索实现代码
-```Python
+```python
def dfs_stack(graph, start):
print(start) # 访问节点 start
visited = set(start) # 使用 visited 标记访问过的节点,先标记 start
@@ -129,7 +129,7 @@ def dfs_stack(graph, start):
**示例**:
-```Python
+```python
输入:grid = [
["1","1","1","1","0"],
["1","1","0","1","0"],
@@ -164,7 +164,7 @@ def dfs_stack(graph, start):
##### 思路 1:代码
-```Python
+```python
class Solution:
def dfs(self, grid, i, j):
n = len(grid)
@@ -216,7 +216,7 @@ class Solution:

-```Python
+```python
输入:adjList = [[2,4],[1,3],[2,4],[1,3]]
输出:[[2,4],[1,3],[2,4],[1,3]]
解释:
@@ -229,7 +229,7 @@ class Solution:

-```Python
+```python
输入:adjList = [[2],[1]]
输出:[[2],[1]]
```
@@ -251,7 +251,7 @@ class Solution:
##### 思路 1:代码
-```Python
+```python
class Solution:
def cloneGraph(self, node: 'Node') -> 'Node':
if not node:
diff --git a/Contents/08.Graph/02.Graph-Traversal/03.Graph-BFS.md b/Contents/08.Graph/02.Graph-Traversal/03.Graph-BFS.md
index 4f085d05..49d93a7b 100644
--- a/Contents/08.Graph/02.Graph-Traversal/03.Graph-BFS.md
+++ b/Contents/08.Graph/02.Graph-Traversal/03.Graph-BFS.md
@@ -10,7 +10,7 @@
我们用邻接字典的方式存储无向图结构,对应结构代码如下:
-```Python
+```python
# 定义无向图结构
graph = {
"A": ["B", "C"],
@@ -46,7 +46,7 @@ graph = {
### 3.2 基于队列实现的广度优先搜索实现代码
-```Python
+```python
import collections
def bfs(graph, start):
@@ -91,7 +91,7 @@ def bfs(graph, start):

-```Python
+```python
输入:adjList = [[2,4],[1,3],[2,4],[1,3]]
输出:[[2,4],[1,3],[2,4],[1,3]]
解释:
@@ -104,7 +104,7 @@ def bfs(graph, start):

-```Python
+```python
输入:adjList = [[2],[1]]
输出:[[2],[1]]
```
@@ -125,7 +125,7 @@ def bfs(graph, start):
##### 思路 1:代码
-```Python
+```python
class Solution:
def cloneGraph(self, node: 'Node') -> 'Node':
if not node:
@@ -176,7 +176,7 @@ class Solution:

-```Python
+```python
输入:grid = [[0,0,1,0,0,0,0,1,0,0,0,0,0],[0,0,0,0,0,0,0,1,1,1,0,0,0],[0,1,1,0,1,0,0,0,0,0,0,0,0],[0,1,0,0,1,1,0,0,1,0,1,0,0],[0,1,0,0,1,1,0,0,1,1,1,0,0],[0,0,0,0,0,0,0,0,0,0,1,0,0],[0,0,0,0,0,0,0,1,1,1,0,0,0],[0,0,0,0,0,0,0,1,1,0,0,0,0]]
输出:6
解释:答案不应该是 11 ,因为岛屿只能包含水平或垂直这四个方向上的 1 。
@@ -199,7 +199,7 @@ class Solution:
##### 思路 1:代码
-```Python
+```python
import collections
class Solution:
diff --git a/Contents/08.Graph/02.Graph-Traversal/05.Graph-Topological-Sorting.md b/Contents/08.Graph/02.Graph-Traversal/05.Graph-Topological-Sorting.md
index 53c891e5..7248f982 100644
--- a/Contents/08.Graph/02.Graph-Traversal/05.Graph-Topological-Sorting.md
+++ b/Contents/08.Graph/02.Graph-Traversal/05.Graph-Topological-Sorting.md
@@ -31,7 +31,7 @@
#### 2.1.2 Kahn 算法的实现代码
-```Python
+```python
import collections
class Solution:
@@ -95,7 +95,7 @@ class Solution:
#### 2.2.2 DFS 深度优先搜索算法实现代码
-```Python
+```python
import collections
class Solution:
@@ -171,7 +171,7 @@ class Solution:
- 示例 1:
-```Python
+```python
输入:numCourses = 2, prerequisites = [[1,0]]
输出:[0,1]
解释:总共有 2 门课程。要学习课程 1,你需要先完成课程 0。因此,正确的课程顺序为 [0,1]。
@@ -179,7 +179,7 @@ class Solution:
- 示例 2:
-```Python
+```python
输入:numCourses = 4, prerequisites = [[1,0],[2,0],[3,1],[3,2]]
输出:[0,2,1,3]
解释:总共有 4 门课程。要学习课程 3,你应该先完成课程 1 和课程 2。并且课程 1 和课程 2 都应该排在课程 0 之后。
@@ -201,7 +201,7 @@ class Solution:
##### 思路 1:代码
-```Python
+```python
import collections
class Solution:
@@ -275,7 +275,7 @@ class Solution:

-```Python
+```python
输入:graph = [[1,2],[2,3],[5],[0],[5],[],[]]
输出:[2,4,5,6]
解释:示意图如上。
@@ -285,7 +285,7 @@ class Solution:
- 示例 2:
-```Python
+```python
输入:graph = [[1,2,3,4],[1,2],[3,4],[0,4],[]]
输出:[4]
解释:
@@ -304,7 +304,7 @@ class Solution:
##### 思路 1:代码
-```Python
+```python
class Solution:
# 拓扑排序,graph 中包含所有顶点的有向边关系(包括无边顶点)
def topologicalSortingKahn(self, graph: dict):
diff --git a/Contents/08.Graph/03.Gaph-Spanning-Tree/01.Gaph-Minimum-Spanning-Tree.md b/Contents/08.Graph/03.Gaph-Spanning-Tree/01.Gaph-Minimum-Spanning-Tree.md
index 83fdacfb..10cf4435 100644
--- a/Contents/08.Graph/03.Gaph-Spanning-Tree/01.Gaph-Minimum-Spanning-Tree.md
+++ b/Contents/08.Graph/03.Gaph-Spanning-Tree/01.Gaph-Minimum-Spanning-Tree.md
@@ -42,7 +42,7 @@
### 2.3 Prim 算法的实现代码
-```Python
+```python
```
@@ -68,6 +68,6 @@
### 3.3 Kruskal 算法的实现代码
-```Python
+```python
```
\ No newline at end of file
diff --git a/Contents/08.Graph/04.Graph-Shortest-Path/01.Graph-Single-Source-Shortest-Path-01.md b/Contents/08.Graph/04.Graph-Shortest-Path/01.Graph-Single-Source-Shortest-Path-01.md
index f6f3f1e0..6152ecb6 100644
--- a/Contents/08.Graph/04.Graph-Shortest-Path/01.Graph-Single-Source-Shortest-Path-01.md
+++ b/Contents/08.Graph/04.Graph-Shortest-Path/01.Graph-Single-Source-Shortest-Path-01.md
@@ -24,7 +24,7 @@
### 2.3 Dijkstra 算法的实现代码
-```Python
+```python
```
@@ -36,7 +36,7 @@
### 3.3 Bellman-Ford 算法的实现代码
-```Python
+```python
```
@@ -48,6 +48,6 @@
### 4.3 SPFA 算法的实现代码
-```Python
+```python
```
diff --git a/Contents/09.Algorithm-Base/01.Enumeration-Algorithm/01.Enumeration-Algorithm.md b/Contents/09.Algorithm-Base/01.Enumeration-Algorithm/01.Enumeration-Algorithm.md
index 09631a76..35b9bb3b 100644
--- a/Contents/09.Algorithm-Base/01.Enumeration-Algorithm/01.Enumeration-Algorithm.md
+++ b/Contents/09.Algorithm-Base/01.Enumeration-Algorithm/01.Enumeration-Algorithm.md
@@ -51,7 +51,7 @@
1. 根据枚举对象、枚举范围和判断条件,我们可以顺利写出对应的代码。
- ```Python
+ ```python
class Solution:
def buyChicken(self):
for x in range(101):
@@ -66,7 +66,7 @@
1. 在上面的代码中,我们枚举了 $x$、$y$、$z$,但其实根据方程式 $x + y + z = 100$,得知:$z$ 可以通过 $z = 100 - x - y$ 而得到,这样我们就不用再枚举 $z$ 了。
2. 在上面的代码中,对 $x$、$y$ 的枚举范围是 $[0, 100]$,但其实如果所有钱用来买公鸡,最多只能买 $20$ 只,同理,全用来买母鸡,最多只能买 $33$ 只。所以对 $x$ 的枚举范围可改为 $[0, 20]$,$y$ 的枚举范围可改为 $[0, 33]$。
- ```Python
+ ```python
class Solution:
def buyChicken(self):
for x in range(21):
@@ -102,7 +102,7 @@
- 示例 1:
-```Python
+```python
输入:nums = [2,7,11,15], target = 9
输出:[0,1]
解释:因为 nums[0] + nums[1] == 9 ,返回 [0, 1] 。
@@ -110,7 +110,7 @@
- 示例 2:
-```Python
+```python
输入:nums = [3,2,4], target = 6
输出:[1,2]
```
@@ -126,7 +126,7 @@
##### 思路 1:代码
-```Python
+```python
class Solution:
def twoSum(self, nums: List[int], target: int) -> List[int]:
for i in range(len(nums)):
@@ -161,7 +161,7 @@ class Solution:
- 示例 1:
-```Python
+```python
输入 n = 10
输出 4
解释 小于 10 的质数一共有 4 个, 它们是 2, 3, 5, 7。
@@ -169,7 +169,7 @@ class Solution:
- 示例 2:
-```Python
+```python
输入:n = 1
输出:0
```
@@ -192,7 +192,7 @@ class Solution:
##### 思路 1:代码
-```Python
+```python
class Solution:
def isPrime(self, x):
for i in range(2, int(pow(x, 0.5)) + 1):
@@ -234,7 +234,7 @@ class Solution:
- 示例 1:
-```Python
+```python
输入 n = 5
输出 2
解释 平方和三元组为 (3,4,5) 和 (4,3,5)。
@@ -242,7 +242,7 @@ class Solution:
- 示例 2:
-```Python
+```python
输入:n = 10
输出:4
解释:平方和三元组为 (3,4,5),(4,3,5),(6,8,10) 和 (8,6,10)。
@@ -262,7 +262,7 @@ class Solution:
##### 思路 1:代码
-```Python
+```python
class Solution:
def countTriples(self, n: int) -> int:
cnt = 0
diff --git a/Contents/09.Algorithm-Base/02.Recursive-Algorithm/01.Recursive-Algorithm.md b/Contents/09.Algorithm-Base/02.Recursive-Algorithm/01.Recursive-Algorithm.md
index 24b5175e..81823e2d 100644
--- a/Contents/09.Algorithm-Base/02.Recursive-Algorithm/01.Recursive-Algorithm.md
+++ b/Contents/09.Algorithm-Base/02.Recursive-Algorithm/01.Recursive-Algorithm.md
@@ -8,7 +8,7 @@ $fact(n) = \begin{cases} 1 & \text{n = 0} \cr n * fact(n - 1) & \text{n > 0} \e
根据阶乘计算方法的数学定义,我们可以使用调用函数自身的方式来实现阶乘函数 `fact(n)` ,其实现代码可以写作:
-```Python
+```python
def fact(n):
if n == 0:
return 1
@@ -17,7 +17,7 @@ def fact(n):
以 `n = 6` 为例,上述代码中阶乘函数 `fact(6):` 的计算过程如下:
-```Python
+```python
fact(6)
= 6 * fact(5)
= 6 * (5 * fact(4))
@@ -145,7 +145,7 @@ fact(6)
根据上述递归书写的步骤,我们就可以写出递归算法的代码了。递归算法的伪代码如下:
-```Python
+```python
def recursion(大规模问题):
if 递归终止条件:
递归终止时的处理方法
@@ -206,7 +206,7 @@ $f(n) = \begin{cases} 0 & n = 0 \cr 1 & n = 1 \cr f(n - 2) + f(n - 1) & n > 1 \e
- 示例 1:
-```Python
+```python
输入:n = 2
输出:1
解释:F(2) = F(1) + F(0) = 1 + 0 = 1
@@ -214,7 +214,7 @@ $f(n) = \begin{cases} 0 & n = 0 \cr 1 & n = 1 \cr f(n - 2) + f(n - 1) & n > 1 \e
- 示例 2:
-```Python
+```python
输入:n = 3
输出:2
解释:F(3) = F(2) + F(1) = 1 + 1 = 2
@@ -237,7 +237,7 @@ $f(n) = \begin{cases} 0 & n = 0 \cr 1 & n = 1 \cr f(n - 2) + f(n - 1) & n > 1 \e
##### 思路 1:代码
-```Python
+```python
class Solution:
def fib(self, n: int) -> int:
if n == 0:
@@ -273,7 +273,7 @@ class Solution:
- 示例 1:
-```Python
+```python
输入:[3,9,20,null,null,15,7]
对应二叉树
3
@@ -301,7 +301,7 @@ class Solution:
##### 思路 1:代码
-```Python
+```python
class Solution:
def maxDepth(self, root: Optional[TreeNode]) -> int:
if not root:
diff --git a/Contents/09.Algorithm-Base/03.Divide-And-Conquer-Algorithm/01.Divide-And-Conquer-Algorithm.md b/Contents/09.Algorithm-Base/03.Divide-And-Conquer-Algorithm/01.Divide-And-Conquer-Algorithm.md
index 2f7efd7f..5db873ac 100644
--- a/Contents/09.Algorithm-Base/03.Divide-And-Conquer-Algorithm/01.Divide-And-Conquer-Algorithm.md
+++ b/Contents/09.Algorithm-Base/03.Divide-And-Conquer-Algorithm/01.Divide-And-Conquer-Algorithm.md
@@ -45,7 +45,7 @@
按照分而治之的策略,在编写分治算法的代码时,也是按照上面的 $3$ 个步骤来编写的,其对应的伪代码如下:
-```Python
+```python
def divide_and_conquer(problem): # problem 为问题规模
if problem < d: # 当问题规模足够小时,直接解决该问题
return solove(); # 直接求解
@@ -133,7 +133,7 @@ $T(n) = \begin{cases} \begin{array} \ O{(1)} & n = 1 \cr 2T(n/2) + O(n) & n > 1
**示例**:
-```Python
+```python
输入 nums = [5,2,3,1]
输出 [1,2,3,5]
```
@@ -152,7 +152,7 @@ $T(n) = \begin{cases} \begin{array} \ O{(1)} & n = 1 \cr 2T(n/2) + O(n) & n > 1
#### 4.1.4 代码
-```Python
+```python
class Solution:
def merge(self, left_arr, right_arr): # 合并
arr = []
@@ -201,7 +201,7 @@ class Solution:
**示例**:
-```Python
+```python
输入 nums = [-1,0,3,5,9,12], target = 9
输出 4
解释 9 出现在 nums 中并且下标为 4
@@ -225,7 +225,7 @@ class Solution:
二分查找问题的非递归实现的分治算法代码如下:
-```Python
+```python
class Solution:
def search(self, nums: List[int], target: int) -> int:
left = 0
diff --git a/Contents/09.Algorithm-Base/04.Backtracking-Algorithm/01.Backtracking-Algorithm.md b/Contents/09.Algorithm-Base/04.Backtracking-Algorithm/01.Backtracking-Algorithm.md
index af90c8df..0db8402f 100644
--- a/Contents/09.Algorithm-Base/04.Backtracking-Algorithm/01.Backtracking-Algorithm.md
+++ b/Contents/09.Algorithm-Base/04.Backtracking-Algorithm/01.Backtracking-Algorithm.md
@@ -45,7 +45,7 @@
根据上文的思路和决策树,我们来写一下全排列的回溯算法代码(假设给定数组 `nums` 中不存在重复元素)。则代码如下所示:
-```Python
+```python
class Solution:
def permute(self, nums: List[int]) -> List[List[int]]:
res = [] # 存放所有符合条件结果的集合
@@ -69,7 +69,7 @@ class Solution:
根据上文全排列的回溯算法代码,我们可以提炼出回溯算法的通用模板,回溯算法的通用模板代码如下所示:
-```Python
+```python
res = [] # 存放所欲符合条件结果的集合
path = [] # 存放当前符合条件的结果
def backtracking(nums): # nums 为选择元素列表
@@ -145,7 +145,7 @@ backtracking(nums)
根据当前可选择的元素列表、给定的约束条件(例如之前已经出现的数字在接下来要选择的数字中不能再次出现)、存放当前状态的变量,我们就可以写出回溯函数的主体部分了。即:
-```Python
+```python
for i in range(len(nums)): # 枚举可选元素列表
if 满足约束条件: # 约束条件
path.append(nums[i]) # 选择元素
@@ -181,14 +181,14 @@ for i in range(len(nums)): # 枚举可选元素列表
- 示例 1:
-```Python
+```python
输入 nums = [1,2,3]
输出 [[],[1],[2],[1,2],[3],[1,3],[2,3],[1,2,3]]
```
- 示例 2:
-```Python
+```python
输入:nums = [0]
输出:[[],[0]]
```
@@ -222,7 +222,7 @@ for i in range(len(nums)): # 枚举可选元素列表
- 选择元素:将其添加到当前子集数组 `path` 中。
- 递归搜索:在选择该元素的情况下,继续递归考虑下一个位置上的元素。
- 撤销选择:将该元素从当前子集数组 `path` 中移除。
- ```Python
+ ```python
for i in range(index, len(nums)): # 枚举可选元素列表
path.append(nums[i]) # 选择元素
backtracking(nums, i + 1) # 递归搜索
@@ -235,7 +235,7 @@ for i in range(len(nums)): # 枚举可选元素列表
##### 思路 1:代码
-```Python
+```python
class Solution:
def subsets(self, nums: List[int]) -> List[List[int]]:
res = [] # 存放所有符合条件结果的集合
@@ -281,7 +281,7 @@ class Solution:
- 示例 1:
-```Python
+```python
输入:n = 4
输出:[[".Q..","...Q","Q...","..Q."],["..Q.","Q...","...Q",".Q.."]]
解释:如下图所示,4 皇后问题存在 2 个不同的解法。
@@ -323,7 +323,7 @@ class Solution:
- 递归搜索:在该位置放置皇后的情况下,继续递归考虑下一行。
- 撤销选择:将棋盘上 `row, col` 位置设置为 `.`。
- ```Python
+ ```python
# 判断当前位置 row, col 是否与之前放置的皇后发生冲突
def isValid(self, n: int, row: int, col: int, chessboard: List[List[str]]):
for i in range(row):
@@ -346,7 +346,7 @@ class Solution:
return True
```
- ```Python
+ ```python
for col in range(n): # 枚举可放置皇后的列
if self.isValid(n, row, col, chessboard): # 如果该位置与之前放置的皇后不发生冲突
chessboard[row][col] = 'Q' # 选择 row, col 位置放置皇后
@@ -360,7 +360,7 @@ class Solution:
##### 思路 1:代码
-```Python
+```python
class Solution:
res = []
def backtrack(self, n: int, row: int, chessboard: List[List[str]]):
diff --git a/Contents/09.Algorithm-Base/05.Greedy-Algorithm/01.Greedy-Algorithm.md b/Contents/09.Algorithm-Base/05.Greedy-Algorithm/01.Greedy-Algorithm.md
index 9089b182..23588721 100644
--- a/Contents/09.Algorithm-Base/05.Greedy-Algorithm/01.Greedy-Algorithm.md
+++ b/Contents/09.Algorithm-Base/05.Greedy-Algorithm/01.Greedy-Algorithm.md
@@ -90,7 +90,7 @@
- 示例 1:
-```Python
+```python
输入:g = [1,2,3], s = [1,1]
输出:1
解释:你有三个孩子和两块小饼干,3 个孩子的胃口值分别是:1, 2, 3。虽然你有两块小饼干,由于他们的尺寸都是 1,你只能让胃口值是 1 的孩子满足。所以应该输出 1。
@@ -98,7 +98,7 @@
- 示例 2:
-```Python
+```python
输入: g = [1,2], s = [1,2,3]
输出: 2
解释: 你有两个孩子和三块小饼干,2个孩子的胃口值分别是1, 2。你拥有的饼干数量和尺寸都足以让所有孩子满足。所以你应该输出 2。
@@ -128,7 +128,7 @@
##### 思路 1:代码
-```Python
+```python
class Solution:
def findContentChildren(self, g: List[int], s: List[int]) -> int:
g.sort()
@@ -173,7 +173,7 @@ class Solution:
- 示例 1:
-```Python
+```python
输入:intervals = [[1,2],[2,3],[3,4],[1,3]]
输出:1
解释:移除 [1,3] 后,剩下的区间没有重叠。
@@ -181,7 +181,7 @@ class Solution:
- 示例 2:
-```Python
+```python
输入: intervals = [ [1,2], [1,2], [1,2] ]
输出: 2
解释: 你需要移除两个 [1,2] 来使剩下的区间没有重叠。
@@ -210,7 +210,7 @@ class Solution:
##### 思路 1:代码
-```Python
+```python
class Solution:
def eraseOverlapIntervals(self, intervals: List[List[int]]) -> int:
if not intervals:
diff --git a/Contents/09.Algorithm-Base/06.Bit-Operation/01.Bit-Operation.md b/Contents/09.Algorithm-Base/06.Bit-Operation/01.Bit-Operation.md
index cfa147d6..4410f2ed 100644
--- a/Contents/09.Algorithm-Base/06.Bit-Operation/01.Bit-Operation.md
+++ b/Contents/09.Algorithm-Base/06.Bit-Operation/01.Bit-Operation.md
@@ -56,14 +56,14 @@ $\begin{aligned} 106 \div 2 = 53 & \text{(余 0)} \cr 53 \div 2 = 26 & \text
我们先来看下这 $6$ 种位运算的规则,再来进行详细讲解。
-| 运算符 | 描述 | 规则 |
-| ------------------- | -------------- | ------------------------------------------------------------ |
-| `&` | 按位与运算符 | 只有对应的两个二进位都为 $1$ 时,结果位才为 $1$。 |
-| |
| 按位或运算符 | 只要对应的两个二进位有一个为 $1$ 时,结果位就为 $1$。 |
-| `^` | 按位异或运算符 | 对应的两个二进位相异时,结果位为 $1$,二进位相同时则结果位为 $0$。 |
-| `~` | 取反运算符 | 对二进制数的每个二进位取反,使数字 $1$ 变为 $0$,$0$ 变为 $1$。 |
+| 运算符 | 描述 | 规则 |
+| ------------------- | -------------- | ----------------------------------------------------------------------------------------- |
+| |
| 按位或运算符 | 只要对应的两个二进位有一个为 $1$ 时,结果位就为 $1$。 |
+| `&` | 按位与运算符 | 只有对应的两个二进位都为 $1$ 时,结果位才为 $1$。 |
| `<<` | 左移运算符 | 将二进制数的各个二进位全部左移若干位。`<<` 右侧数字指定了移动位数,高位丢弃,低位补 $0$。 |
| `>>` | 右移运算符 | 对二进制数的各个二进位全部右移若干位。`>>` 右侧数字指定了移动位数,低位丢弃,高位补 $0$。 |
+| `^` | 按位异或运算符 | 对应的两个二进位相异时,结果位为 $1$,二进位相同时则结果位为 $0$。 |
+| `~` | 取反运算符 | 对二进制数的每个二进位取反,使数字 $1$ 变为 $0$,$0$ 变为 $1$。 |
### 2.1 按位与运算
@@ -176,7 +176,7 @@ $\begin{aligned} 106 \div 2 = 53 & \text{(余 0)} \cr 53 \div 2 = 26 & \text
通过按位异或运算可以实现交换两个数的目的(只能用于交换两个整数)。
-```Python
+```python
a, b = 10, 20
a ^= b
b ^= a
@@ -196,7 +196,7 @@ print(a, b)
具体代码如下:
-```Python
+```python
class Solution:
def hammingWeight(self, n: int) -> int:
cnt = 0
@@ -224,28 +224,28 @@ class Solution:
### 3.2 位运算的常用操作总结
-| 功 能 | 位运算 | 示例 |
-| ----------------------------------------- | -------------------------------- | ---------------------- |
-| **去掉最后一位** | x >> 1
| `101101 -> 10110` |
-| **在最后加一个 `0`** | x << 1
| `101101 -> 1011010` |
-| **在最后加一个 `1`** | (x << 1) + 1
| `101101 -> 1011011` |
-| **把最后一位变成 `1`** | x | 1
| `101100 -> 101101` |
-| **把最后一位变成 `0`** | x | 1 - 1
| `101101 -> 101100` |
-| **最后一位取反** | x ^ 1
| `101101 -> 101100` |
-| **把右数第 `k` 位变成 `1`** | x | (1 << (k - 1))
| `101001 -> 101101, k = 3` |
-| **把右数第 `k` 位变成 `0`** | x & ~(1 << (k - 1))
| `101101 -> 101001, k = 3` |
-| **右数第 `k` 位取反** | x ^ (1 << (k - 1))
| `101001 -> 101101, k = 3` |
-| **取末尾 `3` 位** | x & 7
| `1101101 -> 101` |
-| **取末尾 `k` 位** | x & 15
| `1101101 -> 1101, k = 4` |
-| **取右数第 `k` 位** | x >> (k - 1) & 1
| `1101101 -> 1, k = 4` |
-| **把末尾 `k` 位变成 `1`** | x | (1 << k - 1)
| `101001 -> 101111, k = 4` |
-| **末尾 `k` 位取反** | x ^ (1 << k - 1)
| `101001 -> 100110, k = 4` |
-| **把右边连续的 `1` 变成 `0`** | x & (x + 1)
| `100101111 -> 100100000` |
-| **把右边起第一个 `0` 变成 `1`** | x | (x + 1)
| `100101111 -> 100111111` |
-| **把右边连续的 `0` 变成 `1`** | x | (x - 1)
| `11011000 -> 11011111` |
-| **只保留右边连续的 `1`** | (x ^ (x + 1)) >> 1
| `100101111 -> 1111` |
-| **去掉右边起第一个 `1` 的左边** | x & (x ^ (x - 1))
或 x & (-x)
| `100101000 -> 1000` |
-| **从右边开始,把最后一个 `1` 改写成 `0`** | x & (x - 1)
| `100101000 -> 100100000` |
+| 功 能 | 位运算 | 示例 |
+| ----------------------------------------- | ------------------------------------------------------- | ------------------------- |
+| **从右边开始,把最后一个 `1` 改写成 `0`** | x & (x - 1)
| `100101000 -> 100100000` |
+| **去掉右边起第一个 `1` 的左边** | x & (x ^ (x - 1))
或 x & (-x)
| `100101000 -> 1000` |
+| **去掉最后一位** | x >> 1
| `101101 -> 10110` |
+| **取右数第 `k` 位** | x >> (k - 1) & 1
| `1101101 -> 1, k = 4` |
+| **取末尾 `3` 位** | x & 7
| `1101101 -> 101` |
+| **取末尾 `k` 位** | x & 15
| `1101101 -> 1101, k = 4` |
+| **只保留右边连续的 `1`** | (x ^ (x + 1)) >> 1
| `100101111 -> 1111` |
+| **右数第 `k` 位取反** | x ^ (1 << (k - 1))
| `101001 -> 101101, k = 3` |
+| **在最后加一个 `0`** | x << 1
| `101101 -> 1011010` |
+| **在最后加一个 `1`** | (x << 1) + 1
| `101101 -> 1011011` |
+| **把右数第 `k` 位变成 `0`** | x & ~(1 << (k - 1))
| `101101 -> 101001, k = 3` |
+| **把右数第 `k` 位变成 `1`** | x | (1 << (k - 1))
| `101001 -> 101101, k = 3` |
+| **把右边起第一个 `0` 变成 `1`** | x | (x + 1)
| `100101111 -> 100111111` |
+| **把右边连续的 `0` 变成 `1`** | x | (x - 1)
| `11011000 -> 11011111` |
+| **把右边连续的 `1` 变成 `0`** | x & (x + 1)
| `100101111 -> 100100000` |
+| **把最后一位变成 `0`** | x | 1 - 1
| `101101 -> 101100` |
+| **把最后一位变成 `1`** | x | 1
| `101100 -> 101101` |
+| **把末尾 `k` 位变成 `1`** | x | (1 << k - 1)
| `101001 -> 101111, k = 4` |
+| **最后一位取反** | x ^ 1
| `101101 -> 101100` |
+| **末尾 `k` 位取反** | x ^ (1 << k - 1)
| `101001 -> 100110, k = 4` |
### 3.3 二进制枚举子集
@@ -296,7 +296,7 @@ class Solution:
#### 3.3.2 二进制枚举子集代码
-```Python
+```python
class Solution:
def subsets(self, S): # 返回集合 S 的所有子集
n = len(S) # n 为集合 S 的元素个数
diff --git a/Contents/10.Dynamic-Programming/01.Dynamic-Programming-Basic/01.Dynamic-Programming-Basic.md b/Contents/10.Dynamic-Programming/01.Dynamic-Programming-Basic/01.Dynamic-Programming-Basic.md
index 9d06b290..3263fbcb 100644
--- a/Contents/10.Dynamic-Programming/01.Dynamic-Programming-Basic/01.Dynamic-Programming-Basic.md
+++ b/Contents/10.Dynamic-Programming/01.Dynamic-Programming-Basic/01.Dynamic-Programming-Basic.md
@@ -43,7 +43,7 @@
具体代码如下:
-```Python
+```python
class Solution:
def fib(self, n: int) -> int:
if n == 0:
@@ -154,7 +154,7 @@ class Solution:
- 示例 1:
-```Python
+```python
输入:n = 2
输出:1
解释:F(2) = F(1) + F(0) = 1 + 0 = 1
@@ -162,7 +162,7 @@ class Solution:
- 示例 2:
-```Python
+```python
输入:n = 3
输出:2
解释:F(3) = F(2) + F(1) = 1 + 1 = 2
@@ -192,7 +192,7 @@ class Solution:
#### 4.1.4 代码
-```Python
+```python
class Solution:
def fib(self, n: int) -> int:
if n <= 1:
@@ -232,7 +232,7 @@ class Solution:
- 示例 1:
-```Python
+```python
输入:n = 2
输出:2
解释:有两种方法可以爬到楼顶。
@@ -242,7 +242,7 @@ class Solution:
- 示例 2:
-```Python
+```python
输入:n = 3
输出:3
解释:有三种方法可以爬到楼顶。
@@ -279,7 +279,7 @@ class Solution:
#### 4.2.4 代码
-```Python
+```python
class Solution:
def climbStairs(self, n: int) -> int:
dp = [0 for _ in range(n + 1)]
@@ -317,14 +317,14 @@ class Solution:
- 示例 1:
-```Python
+```python
输入:m = 3, n = 7
输出:28
```
- 示例 2:
-```Python
+```python
输入:m = 3, n = 2
输出:3
解释:
@@ -362,7 +362,7 @@ class Solution:
#### 4.3.4 代码
-```Python
+```python
class Solution:
def uniquePaths(self, m: int, n: int) -> int:
dp = [[0 for _ in range(n)] for _ in range(m)]
diff --git a/Contents/10.Dynamic-Programming/02.Memoization/01.Memoization.md b/Contents/10.Dynamic-Programming/02.Memoization/01.Memoization.md
index d52b55d5..2791c496 100644
--- a/Contents/10.Dynamic-Programming/02.Memoization/01.Memoization.md
+++ b/Contents/10.Dynamic-Programming/02.Memoization/01.Memoization.md
@@ -14,7 +14,7 @@
使用「记忆化搜索」方法解决斐波那契数列的代码如下:
-```Python
+```python
class Solution:
def fib(self, n: int) -> int:
# 使用数组保存已经求解过的 f(k) 的结果
@@ -96,7 +96,7 @@ class Solution:
- 示例 1:
-```Python
+```python
输入:nums = [1,1,1,1,1], target = 3
输出:5
解释:一共有 5 种方法让最终目标和为 3。
@@ -109,7 +109,7 @@ class Solution:
- 示例 2:
-```Python
+```python
输入:nums = [1], target = 1
输出:1
```
@@ -132,7 +132,7 @@ class Solution:
##### 思路 1:代码
-```Python
+```python
class Solution:
def findTargetSumWays(self, nums: List[int], target: int) -> int:
size = len(nums)
@@ -174,7 +174,7 @@ class Solution:
##### 思路 2:代码
-```Python
+```python
class Solution:
def findTargetSumWays(self, nums: List[int], target: int) -> int:
size = len(nums)
@@ -224,7 +224,7 @@ class Solution:
- 示例 1:
-```Python
+```python
输入:n = 4
输出:4
解释:
@@ -234,7 +234,7 @@ T_4 = 1 + 1 + 2 = 4
- 示例 2:
-```Python
+```python
输入:n = 25
输出:1389537
```
@@ -253,7 +253,7 @@ T_4 = 1 + 1 + 2 = 4
##### 思路 1:代码
-```Python
+```python
class Solution:
def tribonacci(self, n: int) -> int:
# 使用数组保存已经求解过的 T(k) 的结果
diff --git a/Contents/10.Dynamic-Programming/03.Linear-DP/01.Linear-DP-01.md b/Contents/10.Dynamic-Programming/03.Linear-DP/01.Linear-DP-01.md
index ff967536..d240e9ee 100644
--- a/Contents/10.Dynamic-Programming/03.Linear-DP/01.Linear-DP-01.md
+++ b/Contents/10.Dynamic-Programming/03.Linear-DP/01.Linear-DP-01.md
@@ -50,7 +50,7 @@
- 示例 1:
-```Python
+```python
输入:nums = [10,9,2,5,3,7,101,18]
输出:4
解释:最长递增子序列是 [2,3,7,101],因此长度为 4。
@@ -58,7 +58,7 @@
- 示例 2:
-```Python
+```python
输入:nums = [0,1,0,3,2,3]
输出:4
```
@@ -97,7 +97,7 @@
##### 思路 1:动态规划代码
-```Python
+```python
class Solution:
def lengthOfLIS(self, nums: List[int]) -> int:
size = len(nums)
@@ -147,7 +147,7 @@ class Solution:
- 示例 1:
-```Python
+```python
输入:nums = [-2,1,-3,4,-1,2,1,-5,4]
输出:6
解释:连续子数组 [4,-1,2,1] 的和最大,为 6。
@@ -155,7 +155,7 @@ class Solution:
- 示例 2:
-```Python
+```python
输入:nums = [1]
输出:1
```
@@ -193,7 +193,7 @@ $dp[i] = \begin{cases} nums[i], & dp[i - 1] < 0 \cr dp[i - 1] + nums[i] & dp[i
##### 思路 1:代码
-```Python
+```python
class Solution:
def maxSubArray(self, nums: List[int]) -> int:
size = len(nums)
@@ -219,7 +219,7 @@ class Solution:
##### 思路 2:代码
-```Python
+```python
class Solution:
def maxSubArray(self, nums: List[int]) -> int:
size = len(nums)
@@ -273,7 +273,7 @@ class Solution:
- 示例 1:
-```Python
+```python
输入: arr = [1,2,3,4,5,6,7,8]
输出: 5
解释: 最长的斐波那契式子序列为 [1,2,3,5,8]。
@@ -281,7 +281,7 @@ class Solution:
- 示例 2:
-```Python
+```python
输入: arr = [1,3,7,11,12,14,18]
输出: 3
解释: 最长的斐波那契式子序列有 [1,11,12]、[3,11,14] 以及 [7,11,18]。
@@ -303,7 +303,7 @@ class Solution:
##### 思路 1:代码
-```Python
+```python
class Solution:
def lenLongestFibSubseq(self, arr: List[int]) -> int:
size = len(arr)
@@ -340,7 +340,7 @@ class Solution:
##### 思路 2:代码
-```Python
+```python
class Solution:
def lenLongestFibSubseq(self, arr: List[int]) -> int:
size = len(arr)
@@ -402,7 +402,7 @@ class Solution:
##### 思路 3:代码
-```Python
+```python
class Solution:
def lenLongestFibSubseq(self, arr: List[int]) -> int:
size = len(arr)
@@ -477,7 +477,7 @@ class Solution:
- 示例 1:
-```Python
+```python
输入:text1 = "abcde", text2 = "ace"
输出:3
解释:最长公共子序列是 "ace",它的长度为 3。
@@ -485,7 +485,7 @@ class Solution:
- 示例 2:
-```Python
+```python
输入:text1 = "abc", text2 = "abc"
输出:3
解释:最长公共子序列是 "abc",它的长度为 3。
@@ -523,7 +523,7 @@ class Solution:
##### 思路 1:代码
-```Python
+```python
class Solution:
def longestCommonSubsequence(self, text1: str, text2: str) -> int:
size1 = len(text1)
@@ -565,7 +565,7 @@ class Solution:
- 示例 1:
-```Python
+```python
输入:nums1 = [1,2,3,2,1], nums2 = [3,2,1,4,7]
输出:3
解释:长度最长的公共子数组是 [3,2,1] 。
@@ -573,7 +573,7 @@ class Solution:
- 示例 2:
-```Python
+```python
输入:nums1 = [0,0,0,0,0], nums2 = [0,0,0,0,0]
输出:5
```
@@ -606,7 +606,7 @@ class Solution:
##### 思路 1:代码
-```Python
+```python
class Solution:
def findLength(self, nums1: List[int], nums2: List[int]) -> int:
size1 = len(nums1)
@@ -657,7 +657,7 @@ class Solution:
- 示例 1:
-```Python
+```python
输入:word1 = "horse", word2 = "ros"
输出:3
解释:
@@ -668,7 +668,7 @@ rose -> ros (删除 'e')
- 示例 2:
-```Python
+```python
输入:word1 = "intention", word2 = "execution"
输出:5
解释:
@@ -714,7 +714,7 @@ $dp[i][j] = \begin{cases} dp[i - 1][j - 1] & word1[i - 1] = word2[j - 1] \cr min
##### 思路 1:代码
-```Python
+```python
class Solution:
def minDistance(self, word1: str, word2: str) -> int:
size1 = len(word1)
diff --git a/Contents/10.Dynamic-Programming/03.Linear-DP/02.Linear-DP-02.md b/Contents/10.Dynamic-Programming/03.Linear-DP/02.Linear-DP-02.md
index d4bb2096..ea89efb2 100644
--- a/Contents/10.Dynamic-Programming/03.Linear-DP/02.Linear-DP-02.md
+++ b/Contents/10.Dynamic-Programming/03.Linear-DP/02.Linear-DP-02.md
@@ -28,7 +28,7 @@

-```Python
+```python
输入:grid = [[1,3,1],[1,5,1],[4,2,1]]
输出:7
解释:因为路径 1→3→1→1→1 的总和最小。
@@ -36,7 +36,7 @@
- 示例 2:
-```Python
+```python
输入:grid = [[1,2,3],[4,5,6]]
输出:12
```
@@ -71,7 +71,7 @@
##### 思路 1:代码
-```Python
+```python
class Solution:
def minPathSum(self, grid: List[List[int]]) -> int:
rows, cols = len(grid), len(grid[0])
@@ -122,7 +122,7 @@ class Solution:

-```Python
+```python
输入:matrix = [["1","0","1","0","0"],["1","0","1","1","1"],["1","1","1","1","1"],["1","0","0","1","0"]]
输出:4
```
@@ -131,7 +131,7 @@ class Solution:

-```Python
+```python
输入:matrix = [["0","1"],["1","0"]]
输出:1
```
@@ -165,7 +165,7 @@ class Solution:
##### 思路 1:代码
-```Python
+```python
class Solution:
def maximalSquare(self, matrix: List[List[str]]) -> int:
rows, cols = len(matrix), len(matrix[0])
@@ -211,7 +211,7 @@ class Solution:
- 示例 1:
-```Python
+```python
输入: n = 2
输出: 1
解释: 2 = 1 + 1, 1 × 1 = 1。
@@ -219,7 +219,7 @@ class Solution:
- 示例 2:
-```Python
+```python
输入: n = 10
输出: 36
解释: 10 = 3 + 3 + 4, 3 × 3 × 4 = 36。
@@ -260,7 +260,7 @@ $dp[i] = max_{1 \le j < i}\lbrace max(j \times (i - j), j \times dp[i - j]) \rbr
##### 思路 1:代码
-```Python
+```python
class Solution:
def integerBreak(self, n: int) -> int:
dp = [0 for _ in range(n + 1)]
@@ -300,7 +300,7 @@ class Solution:
- 示例 1:
-```Python
+```python
输入:3
输出:3
解释
@@ -312,7 +312,7 @@ class Solution:
- 示例 2:
-```Python
+```python
输入:n = 1
输出:0
```
@@ -350,7 +350,7 @@ class Solution:
##### 思路 1:动态规划代码
-```Python
+```python
import math
class Solution:
diff --git a/Contents/10.Dynamic-Programming/04.Knapsack-Problem/01.Knapsack-Problem-01.md b/Contents/10.Dynamic-Programming/04.Knapsack-Problem/01.Knapsack-Problem-01.md
index dfca3ed6..32353904 100644
--- a/Contents/10.Dynamic-Programming/04.Knapsack-Problem/01.Knapsack-Problem-01.md
+++ b/Contents/10.Dynamic-Programming/04.Knapsack-Problem/01.Knapsack-Problem-01.md
@@ -65,7 +65,7 @@ $dp[i][w] = \begin{cases} dp[i - 1][w] & w < weight[i - 1] \cr max \lbrace dp[i
#### 思路 1:代码
-```Python
+```python
class Solution:
# 思路 1:动态规划 + 二维基本思路
def zeroOnePackMethod1(self, weight: [int], value: [int], W: int):
@@ -136,7 +136,7 @@ $dp[w] = \begin{cases} dp[w] & w < weight[i - 1] \cr max \lbrace dp[w], dp[w - w
#### 思路 2:代码
-```Python
+```python
class Solution:
# 思路 2:动态规划 + 滚动数组优化
def zeroOnePackMethod2(self, weight: [int], value: [int], W: int):
@@ -179,7 +179,7 @@ class Solution:
- 示例 1:
-```Python
+```python
输入:nums = [1,5,11,5]
输出:true
解释:数组可以分割成 [1, 5, 5] 和 [11]。
@@ -187,7 +187,7 @@ class Solution:
- 示例 2:
-```Python
+```python
输入:nums = [1,2,3,5]
输出:false
解释:数组不能分割成两个元素和相等的子集。
@@ -232,7 +232,7 @@ $dp[w] = \begin{cases} dp[w] & w < nums[i - 1] \cr max \lbrace dp[w], \quad dp[w
##### 思路 1:代码
-```Python
+```python
class Solution:
# 思路 2:动态规划 + 滚动数组优化
def zeroOnePackMethod2(self, weight: [int], value: [int], W: int):
diff --git a/Contents/10.Dynamic-Programming/04.Knapsack-Problem/02.Knapsack-Problem-02.md b/Contents/10.Dynamic-Programming/04.Knapsack-Problem/02.Knapsack-Problem-02.md
index 498d02da..cafdbc65 100644
--- a/Contents/10.Dynamic-Programming/04.Knapsack-Problem/02.Knapsack-Problem-02.md
+++ b/Contents/10.Dynamic-Programming/04.Knapsack-Problem/02.Knapsack-Problem-02.md
@@ -49,7 +49,7 @@ $dp[i][w] = max \lbrace dp[i - 1][w - k \times weight[i - 1]] + k \times value[i
#### 思路 1:代码
-```Python
+```python
class Solution:
# 思路 1:动态规划 + 二维基本思路
def completePackMethod1(self, weight: [int], value: [int], W: int):
@@ -142,7 +142,7 @@ $\quad dp[i][w] = \begin{cases} dp[i - 1][w] & w < weight[i - 1] \cr max \lbrac
#### 思路 2:代码
-```Python
+```python
class Solution:
# 思路 2:动态规划 + 状态转移方程优化
def completePackMethod2(self, weight: [int], value: [int], W: int):
@@ -209,7 +209,7 @@ $dp[w] = \begin{cases} dp[w] & w < weight[i - 1] \cr max \lbrace dp[w], \quad d
#### 思路 3:代码
-```Python
+```python
class Solution:
# 思路 3:动态规划 + 滚动数组优化
def completePackMethod3(self, weight: [int], value: [int], W: int):
diff --git a/Contents/10.Dynamic-Programming/04.Knapsack-Problem/03.Knapsack-Problem-03.md b/Contents/10.Dynamic-Programming/04.Knapsack-Problem/03.Knapsack-Problem-03.md
index 61263db6..0abf2333 100644
--- a/Contents/10.Dynamic-Programming/04.Knapsack-Problem/03.Knapsack-Problem-03.md
+++ b/Contents/10.Dynamic-Programming/04.Knapsack-Problem/03.Knapsack-Problem-03.md
@@ -35,7 +35,7 @@ $dp[i][w] = max \lbrace dp[i - 1][w - k \times weight[i - 1]] + k \times value[i
#### 思路 1:代码
-```Python
+```python
class Solution:
# 思路 1:动态规划 + 二维基本思路
def multiplePackMethod1(self, weight: [int], value: [int], count: [int], W: int):
@@ -91,7 +91,7 @@ $dp[w] = max \lbrace dp[w - k \times weight[i - 1]] + k \times value[i - 1] \rbr
#### 思路 2:代码
-```Python
+```python
class Solution:
# 思路 2:动态规划 + 滚动数组优化
def multiplePackMethod2(self, weight: [int], value: [int], count: [int], W: int):
@@ -167,7 +167,7 @@ $dp[w] = max \lbrace dp[w - weight \underline{ } new[i - 1]] + value \underline{
#### 思路 3:代码
-```Python
+```python
class Solution:
# 思路 3:动态规划 + 二进制优化
def multiplePackMethod3(self, weight: [int], value: [int], count: [int], W: int):
diff --git a/Contents/10.Dynamic-Programming/04.Knapsack-Problem/04.Knapsack-Problem-04.md b/Contents/10.Dynamic-Programming/04.Knapsack-Problem/04.Knapsack-Problem-04.md
index 98151488..5b255e95 100644
--- a/Contents/10.Dynamic-Programming/04.Knapsack-Problem/04.Knapsack-Problem-04.md
+++ b/Contents/10.Dynamic-Programming/04.Knapsack-Problem/04.Knapsack-Problem-04.md
@@ -22,7 +22,7 @@
#### 思路 1:代码
-```Python
+```python
class Solution:
def mixedPackMethod1(self, weight: [int], value: [int], count: [int], W: int):
weight_new, value_new, count_new = [], [], []
@@ -125,7 +125,7 @@ $dp[i][w] = max \lbrace dp[i - 1][w],dp[i - 1][w - weight[i - 1][k]] + value[i
#### 思路 1:代码
-```Python
+```python
class Solution:
# 思路 1:动态规划 + 二维基本思路
def groupPackMethod1(self, group_count: [int], weight: [[int]], value: [[int]], W: int):
@@ -175,7 +175,7 @@ $dp[w] = max \lbrace dp[w], \quad dp[w - weight[i - 1][k]] + value[i - 1][k] \r
#### 思路 2:代码
-```Python
+```python
class Solution:
# 思路 2:动态规划 + 滚动数组优化
def groupPackMethod2(self, group_count: [int], weight: [[int]], value: [[int]], W: int):
@@ -242,7 +242,7 @@ $dp[i][w][v] = max(dp[i - 1][w][v], dp[i - 1][w - weight[i - 1]][v - volume[i -
#### 思路 1:代码
-```Python
+```python
class Solution:
# 思路 1:动态规划 + 三维基本思路
def twoDCostPackMethod1(self, weight: [int], volume: [int], value: [int], W: int, V: int):
@@ -300,7 +300,7 @@ $dp[w][v] = max \lbrace dp[w][v], \quad dp[w - weight[i - 1]][v - volume[i - 1]]
#### 思路 2:代码
-```Python
+```python
class Solution:
# 思路 2:动态规划 + 滚动数组优化
def twoDCostPackMethod2(self, weight: [int], volume: [int], value: [int], W: int, V: int):
diff --git a/Contents/10.Dynamic-Programming/04.Knapsack-Problem/05.Knapsack-Problem-05.md b/Contents/10.Dynamic-Programming/04.Knapsack-Problem/05.Knapsack-Problem-05.md
index d18b5b4b..f88c41bc 100644
--- a/Contents/10.Dynamic-Programming/04.Knapsack-Problem/05.Knapsack-Problem-05.md
+++ b/Contents/10.Dynamic-Programming/04.Knapsack-Problem/05.Knapsack-Problem-05.md
@@ -37,7 +37,7 @@
#### 思路 1:代码
-```Python
+```python
class Solution:
# 0-1 背包问题 求恰好装满背包的最大价值
def zeroOnePackJustFillUp(self, weight: [int], value: [int], W: int):
@@ -89,7 +89,7 @@ class Solution:
#### 思路 2:代码
-```Python
+```python
class Solution:
# 0-1 背包问题求方案总数
def zeroOnePackNumbers(self, weight: [int], value: [int], W: int):
@@ -140,7 +140,7 @@ class Solution:
#### 思路 3:代码
-```Python
+```python
class Solution:
# 0-1 背包问题求最优方案数 思路 1
def zeroOnePackMaxProfitNumbers1(self, weight: [int], value: [int], W: int):
@@ -203,7 +203,7 @@ class Solution:
#### 思路 4:代码
-```Python
+```python
class Solution:
# 0-1 背包问题求具体方案
def zeroOnePackPrintPath(self, weight: [int], value: [int], W: int):
@@ -265,7 +265,7 @@ class Solution:
#### 思路 5:代码
-```Python
+```python
class Solution:
# 0-1 背包问题求具体方案,要求最小序输出
def zeroOnePackPrintPathMinOrder(self, weight: [int], value: [int], W: int):
diff --git a/Contents/10.Dynamic-Programming/05.Interval-DP/01.Interval-DP.md b/Contents/10.Dynamic-Programming/05.Interval-DP/01.Interval-DP.md
index c867fd12..cf88cf41 100644
--- a/Contents/10.Dynamic-Programming/05.Interval-DP/01.Interval-DP.md
+++ b/Contents/10.Dynamic-Programming/05.Interval-DP/01.Interval-DP.md
@@ -31,7 +31,7 @@
对应代码如下:
-```Python
+```python
for i in range(size - 1, -1, -1): # 枚举区间起点
for j in range(i + 1, size): # 枚举区间终点
# 状态转移方程,计算转移到更大区间后的最优值
@@ -54,7 +54,7 @@ for i in range(size - 1, -1, -1): # 枚举区间起点
对应代码如下:
-```Python
+```python
for l in range(1, n): # 枚举区间长度
for i in range(n): # 枚举区间起点
j = i + l - 1 # 根据起点和长度得到终点
@@ -92,7 +92,7 @@ for l in range(1, n): # 枚举区间长度
- 示例 1:
-```Python
+```python
输入:s = "bbbab"
输出:4
解释:一个可能的最长回文子序列为 "bbbb"。
@@ -100,7 +100,7 @@ for l in range(1, n): # 枚举区间长度
- 示例 2:
-```Python
+```python
输入:s = "cbbd"
输出:2
解释:一个可能的最长回文子序列为 "bb"。
@@ -143,7 +143,7 @@ $dp[i][j] = \begin{cases} max \lbrace dp[i + 1][j - 1] + 2 \rbrace & s[i] = s[j]
##### 思路 1:代码
-```Python
+```python
class Solution:
def longestPalindromeSubseq(self, s: str) -> int:
size = len(s)
@@ -188,7 +188,7 @@ class Solution:
- 示例 1:
-```Python
+```python
输入:nums = [3,1,5,8]
输出:167
解释:
@@ -198,7 +198,7 @@ coins = 3*1*5 + 3*5*8 + 1*3*8 + 1*8*1 = 167
- 示例 2:
-```Python
+```python
输入:nums = [1,5]
输出:10
解释:
@@ -240,7 +240,7 @@ $dp[i][j] = max \lbrace dp[i][k] + dp[k][j] + nums[i] \times nums[k] \times nums
##### 思路 1:代码
-```Python
+```python
class Solution:
def maxCoins(self, nums: List[int]) -> int:
size = len(nums)
@@ -300,7 +300,7 @@ class Solution:

-```Python
+```python
输入:n = 7, cuts = [1,3,4,5]
输出:16
解释:按 [1, 3, 4, 5] 的顺序切割的情况如下所示。
@@ -311,7 +311,7 @@ class Solution:
- 示例 2:
-```Python
+```python
输入:n = 9, cuts = [5,6,1,4,2]
输出:22
解释:如果按给定的顺序切割,则总成本为 25。总成本 <= 25 的切割顺序很多,例如,[4, 6, 5, 2, 1] 的总成本 = 22,是所有可能方案中成本最小的。
@@ -350,7 +350,7 @@ class Solution:
##### 思路 1:代码
-```Python
+```python
class Solution:
def minCost(self, n: int, cuts: List[int]) -> int:
cuts.append(0)
diff --git a/Contents/10.Dynamic-Programming/06.Tree-DP/01.Tree-DP.md b/Contents/10.Dynamic-Programming/06.Tree-DP/01.Tree-DP.md
index a129de70..f36bc332 100644
--- a/Contents/10.Dynamic-Programming/06.Tree-DP/01.Tree-DP.md
+++ b/Contents/10.Dynamic-Programming/06.Tree-DP/01.Tree-DP.md
@@ -53,7 +53,7 @@

-```Python
+```python
输入:root = [1,2,3]
输出:6
解释:最优路径是 2 -> 1 -> 3 ,路径和为 2 + 1 + 3 = 6
@@ -63,7 +63,7 @@

-```Python
+```python
输入:root = [-10,9,20,null,null,15,7]
输出:42
解释:最优路径是 15 -> 20 -> 7 ,路径和为 15 + 20 + 7 = 42
@@ -104,7 +104,7 @@
##### 思路 1:代码
-```Python
+```python
# Definition for a binary tree node.
# class TreeNode:
# def __init__(self, val=0, left=None, right=None):
@@ -163,7 +163,7 @@ class Solution:

-```Python
+```python
输入:parent = [-1,0,0,1,1,2], s = "abacbe"
输出:3
解释:任意一对相邻节点字符都不同的最长路径是:0 -> 1 -> 3 。该路径的长度是 3 ,所以返回 3。
@@ -174,7 +174,7 @@ class Solution:

-```Python
+```python
输入:parent = [-1,0,0,0], s = "aabc"
输出:3
解释:任意一对相邻节点字符都不同的最长路径是:2 -> 0 -> 3 。该路径的长度为 3 ,所以返回 3。
@@ -207,7 +207,7 @@ class Solution:
##### 思路 1:代码
-```Python
+```python
class Solution:
def longestPath(self, parent: List[int], s: str) -> int:
size = len(parent)
@@ -278,7 +278,7 @@ class Solution:

-```Python
+```python
输入:n = 4, edges = [[1,0],[1,2],[1,3]]
输出:[1]
解释:如图所示,当根是标签为 1 的节点时,树的高度是 1 ,这是唯一的最小高度树。
@@ -288,7 +288,7 @@ class Solution:

-```Python
+```python
输入:n = 6, edges = [[3,0],[3,1],[3,2],[3,4],[5,4]]
输出:[3,4]
```
@@ -329,7 +329,7 @@ class Solution:
##### 思路 1:代码
-```Python
+```python
class Solution:
def findMinHeightTrees(self, n: int, edges: List[List[int]]) -> List[int]:
graph = [[] for _ in range(n)]
diff --git a/Contents/10.Dynamic-Programming/07.State-DP/01.State-DP.md b/Contents/10.Dynamic-Programming/07.State-DP/01.State-DP.md
index 7c471b04..a3dd8ac8 100644
--- a/Contents/10.Dynamic-Programming/07.State-DP/01.State-DP.md
+++ b/Contents/10.Dynamic-Programming/07.State-DP/01.State-DP.md
@@ -81,7 +81,7 @@
- 求集合 $A$ 与集合 $B$ 的交集:`A & B`
- 枚举集合 $A$ 的子集(包含 $A$):
- ```Python
+ ```python
subA = A # 从集合 A 开始
while subA > 0:
...
@@ -90,7 +90,7 @@
- 枚举全集的所有子集:
- ```Python
+ ```python
for state in range(1 << n): # state 为子集
for i in range(n): # 枚举第 i 位元素
if (state >> i) & i: # 如果第 i 位元素对应二进制位 1,则表示集合中选取了该元素
@@ -124,7 +124,7 @@
- 示例 1:
-```Python
+```python
输入:nums1 = [1,2], nums2 = [2,3]
输出:2
解释:将 nums2 重新排列得到 [3,2] 。
@@ -133,7 +133,7 @@
- 示例 2:
-```Python
+```python
输入:nums1 = [1,0,3], nums2 = [5,3,4]
输出:8
解释:将 nums2 重新排列得到 [5,4,3] 。
@@ -188,7 +188,7 @@
##### 思路 1:代码
-```Python
+```python
class Solution:
def minimumXORSum(self, nums1: List[int], nums2: List[int]) -> int:
ans = float('inf')
@@ -238,7 +238,7 @@ class Solution:
- 示例 1:
-```Python
+```python
输入:nums = [1,2,3,4,5,6], numSlots = 3
输出:9
解释:一个可行的方案是 [1, 4] 放入篮子 1 中,[2, 6] 放入篮子 2 中,[3, 5] 放入篮子 3 中。
@@ -247,7 +247,7 @@ class Solution:
- 示例 2:
-```Python
+```python
输入:nums = [1,3,10,4,7,1], numSlots = 9
输出:24
解释:一个可行的方案是 [1, 1] 放入篮子 1 中,[3] 放入篮子 3 中,[4] 放入篮子 4 中,[7] 放入篮子 7 中,[10] 放入篮子 9 中。
@@ -300,7 +300,7 @@ class Solution:
##### 思路 1:代码
-```Python
+```python
class Solution:
def maximumANDSum(self, nums: List[int], numSlots: int) -> int:
states = 1 << (numSlots * 2)
diff --git a/Contents/10.Dynamic-Programming/08.Counting-DP/01.Counting-DP.md b/Contents/10.Dynamic-Programming/08.Counting-DP/01.Counting-DP.md
index b6da3d0e..ffaff133 100644
--- a/Contents/10.Dynamic-Programming/08.Counting-DP/01.Counting-DP.md
+++ b/Contents/10.Dynamic-Programming/08.Counting-DP/01.Counting-DP.md
@@ -49,7 +49,7 @@
- 示例 1:
-```Python
+```python
输入:m = 3, n = 7
输出:28
```
@@ -58,7 +58,7 @@
- 示例 2:
-```Python
+```python
输入:m = 3, n = 2
输出:3
解释:
@@ -96,7 +96,7 @@
##### 思路 1:动态规划代码
-```Python
+```python
class Solution:
def uniquePaths(self, m: int, n: int) -> int:
dp = [[0 for _ in range(n)] for _ in range(m)]
@@ -138,7 +138,7 @@ class Solution:
- 示例 1:
-```Python
+```python
输入: n = 2
输出: 1
解释: 2 = 1 + 1, 1 × 1 = 1。
@@ -146,7 +146,7 @@ class Solution:
- 示例 2:
-```Python
+```python
输入: n = 10
输出: 36
解释: 10 = 3 + 3 + 4, 3 × 3 × 4 = 36。
@@ -187,7 +187,7 @@ $dp[i] = max_{1 \le j < i}\lbrace max(j \times (i - j), j \times dp[i - j]) \rbr
##### 思路 1:代码
-```Python
+```python
class Solution:
def integerBreak(self, n: int) -> int:
dp = [0 for _ in range(n + 1)]
diff --git a/Contents/10.Dynamic-Programming/09.Digit-DP/01.Digit-DP.md b/Contents/10.Dynamic-Programming/09.Digit-DP/01.Digit-DP.md
index 17e5f63e..0453bd72 100644
--- a/Contents/10.Dynamic-Programming/09.Digit-DP/01.Digit-DP.md
+++ b/Contents/10.Dynamic-Programming/09.Digit-DP/01.Digit-DP.md
@@ -35,7 +35,7 @@
对应代码如下:
-```Python
+```python
class Solution:
def digitDP(self, n: int) -> int:
# 将 n 转换为字符串 s
@@ -90,7 +90,7 @@ class Solution:
- 示例 1:
-```Python
+```python
输入:n = 20
输出:19
解释:1 到 20 之间所有整数除了 11 以外都是特殊整数。所以总共有 19 个特殊整数。
@@ -98,7 +98,7 @@ class Solution:
- 示例 2:
-```Python
+```python
输入:n = 5
输出:5
解释:1 到 5 所有整数都是特殊整数。
@@ -130,7 +130,7 @@ class Solution:
##### 思路 1:代码
-```Python
+```python
class Solution:
def countSpecialNumbers(self, n: int) -> int:
# 将 n 转换为字符串 s
@@ -193,7 +193,7 @@ class Solution:
- 示例 1:
-```Python
+```python
输入:n = 20
输出:1
解释:具有至少 1 位重复数字的正数(<= 20)只有 11。
@@ -201,7 +201,7 @@ class Solution:
- 示例 2:
-```Python
+```python
输入:n = 100
输出:10
解释:具有至少 1 位重复数字的正数(<= 100)有 11,22,33,44,55,66,77,88,99 和 100。
@@ -236,7 +236,7 @@ class Solution:
##### 思路 1:代码
-```Python
+```python
class Solution:
def numDupDigitsAtMostN(self, n: int) -> int:
# 将 n 转换为字符串 s
@@ -297,14 +297,14 @@ class Solution:
- 示例 1:
-```Python
+```python
输入:n = 13
输出:6
```
- 示例 2:
-```Python
+```python
输入:n = 0
输出:0
```
@@ -333,7 +333,7 @@ class Solution:
##### 思路 1:代码
-```Python
+```python
class Solution:
def countDigitOne(self, n: int) -> int:
# 将 n 转换为字符串 s
diff --git "a/Solutions/0001. \344\270\244\346\225\260\344\271\213\345\222\214.md" "b/Solutions/0001. \344\270\244\346\225\260\344\271\213\345\222\214.md"
index 7d6491f4..52bb228d 100644
--- "a/Solutions/0001. \344\270\244\346\225\260\344\271\213\345\222\214.md"
+++ "b/Solutions/0001. \344\270\244\346\225\260\344\271\213\345\222\214.md"
@@ -20,7 +20,7 @@
- 示例 1:
-```Python
+```python
输入:nums = [2,7,11,15], target = 9
输出:[0,1]
解释:因为 nums[0] + nums[1] == 9 ,返回 [0, 1] 。
@@ -28,7 +28,7 @@
- 示例 2:
-```Python
+```python
输入:nums = [3,2,4], target = 6
输出:[1,2]
```
@@ -42,7 +42,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def twoSum(self, nums: List[int], target: int) -> List[int]:
for i in range(len(nums)):
@@ -67,7 +67,7 @@ class Solution:
### 思路 2:代码
-```Python
+```python
def twoSum(self, nums: List[int], target: int) -> List[int]:
numDict = dict()
for i in range(len(nums)):
diff --git "a/Solutions/0002. \344\270\244\346\225\260\347\233\270\345\212\240.md" "b/Solutions/0002. \344\270\244\346\225\260\347\233\270\345\212\240.md"
index 63163dd0..1c09d8fa 100644
--- "a/Solutions/0002. \344\270\244\346\225\260\347\233\270\345\212\240.md"
+++ "b/Solutions/0002. \344\270\244\346\225\260\347\233\270\345\212\240.md"
@@ -21,7 +21,7 @@

-```Python
+```python
输入:l1 = [2,4,3], l2 = [5,6,4]
输出:[7,0,8]
解释:342 + 465 = 807.
@@ -29,7 +29,7 @@
- 示例 2:
-```Python
+```python
输入:l1 = [0], l2 = [0]
输出:[0]
```
@@ -42,7 +42,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def addTwoNumbers(self, l1: ListNode, l2: ListNode) -> ListNode:
head = curr = ListNode(0)
diff --git "a/Solutions/0003. \346\227\240\351\207\215\345\244\215\345\255\227\347\254\246\347\232\204\346\234\200\351\225\277\345\255\220\344\270\262.md" "b/Solutions/0003. \346\227\240\351\207\215\345\244\215\345\255\227\347\254\246\347\232\204\346\234\200\351\225\277\345\255\220\344\270\262.md"
index 608fdaeb..c6083f1f 100644
--- "a/Solutions/0003. \346\227\240\351\207\215\345\244\215\345\255\227\347\254\246\347\232\204\346\234\200\351\225\277\345\255\220\344\270\262.md"
+++ "b/Solutions/0003. \346\227\240\351\207\215\345\244\215\345\255\227\347\254\246\347\232\204\346\234\200\351\225\277\345\255\220\344\270\262.md"
@@ -18,7 +18,7 @@
- 示例 1:
-```Python
+```python
输入: s = "abcabcbb"
输出: 3
解释: 因为无重复字符的最长子串是 "abc",所以其长度为 3。
@@ -26,7 +26,7 @@
- 示例 2:
-```Python
+```python
输入: s = "bbbbb"
输出: 1
解释: 因为无重复字符的最长子串是 "b",所以其长度为 1。
@@ -47,7 +47,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def lengthOfLongestSubstring(self, s: str) -> int:
left = 0
diff --git "a/Solutions/0004. \345\257\273\346\211\276\344\270\244\344\270\252\346\255\243\345\272\217\346\225\260\347\273\204\347\232\204\344\270\255\344\275\215\346\225\260.md" "b/Solutions/0004. \345\257\273\346\211\276\344\270\244\344\270\252\346\255\243\345\272\217\346\225\260\347\273\204\347\232\204\344\270\255\344\275\215\346\225\260.md"
index f27b92e6..88cf30af 100644
--- "a/Solutions/0004. \345\257\273\346\211\276\344\270\244\344\270\252\346\255\243\345\272\217\346\225\260\347\273\204\347\232\204\344\270\255\344\275\215\346\225\260.md"
+++ "b/Solutions/0004. \345\257\273\346\211\276\344\270\244\344\270\252\346\255\243\345\272\217\346\225\260\347\273\204\347\232\204\344\270\255\344\275\215\346\225\260.md"
@@ -23,7 +23,7 @@
- 示例 1:
-```Python
+```python
输入:nums1 = [1,2], nums2 = [3,4]
输出:2.50000
解释:合并数组 = [1,2,3,4] ,中位数 (2 + 3) / 2 = 2.5
@@ -79,7 +79,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def findMedianSortedArrays(self, nums1: List[int], nums2: List[int]) -> float:
n1 = len(nums1)
diff --git "a/Solutions/0005. \346\234\200\351\225\277\345\233\236\346\226\207\345\255\220\344\270\262.md" "b/Solutions/0005. \346\234\200\351\225\277\345\233\236\346\226\207\345\255\220\344\270\262.md"
index 0943396a..cb323dac 100644
--- "a/Solutions/0005. \346\234\200\351\225\277\345\233\236\346\226\207\345\255\220\344\270\262.md"
+++ "b/Solutions/0005. \346\234\200\351\225\277\345\233\236\346\226\207\345\255\220\344\270\262.md"
@@ -19,7 +19,7 @@
- 示例 1:
-```Python
+```python
输入:s = "babad"
输出:"bab"
解释:"aba" 同样是符合题意的答案。
@@ -27,7 +27,7 @@
- 示例 2:
-```Python
+```python
输入:s = "cbbd"
输出:"bb"
```
@@ -59,7 +59,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def longestPalindrome(self, s: str) -> str:
n = len(s)
diff --git "a/Solutions/0007. \346\225\264\346\225\260\345\217\215\350\275\254.md" "b/Solutions/0007. \346\225\264\346\225\260\345\217\215\350\275\254.md"
index 9fd0e466..05f0791d 100644
--- "a/Solutions/0007. \346\225\264\346\225\260\345\217\215\350\275\254.md"
+++ "b/Solutions/0007. \346\225\264\346\225\260\345\217\215\350\275\254.md"
@@ -31,7 +31,7 @@ ans * 10 + pop > INT_MAX 有两种情况:
## 代码
-```Python
+```python
class Solution:
def reverse(self, x: int) -> int:
INT_MAX_10 = (1<<31)//10
diff --git "a/Solutions/0008. \345\255\227\347\254\246\344\270\262\350\275\254\346\215\242\346\225\264\346\225\260 (atoi).md" "b/Solutions/0008. \345\255\227\347\254\246\344\270\262\350\275\254\346\215\242\346\225\264\346\225\260 (atoi).md"
index fc9852c1..1366bbe4 100644
--- "a/Solutions/0008. \345\255\227\347\254\246\344\270\262\350\275\254\346\215\242\346\225\264\346\225\260 (atoi).md"
+++ "b/Solutions/0008. \345\255\227\347\254\246\344\270\262\350\275\254\346\215\242\346\225\264\346\225\260 (atoi).md"
@@ -27,7 +27,7 @@
- 示例 1:
-```Python
+```python
输入:s = "42"
输出:42
解释:加粗的字符串为已经读入的字符,插入符号是当前读取的字符。
@@ -43,7 +43,7 @@
- 示例 2:
-```Python
+```python
输入:s = " -42"
输出:-42
解释:
@@ -69,7 +69,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def myAtoi(self, s: str) -> int:
num_str = ""
diff --git "a/Solutions/0009. \345\233\236\346\226\207\346\225\260.md" "b/Solutions/0009. \345\233\236\346\226\207\346\225\260.md"
index 6fa5c46f..1b9ad70e 100644
--- "a/Solutions/0009. \345\233\236\346\226\207\346\225\260.md"
+++ "b/Solutions/0009. \345\233\236\346\226\207\346\225\260.md"
@@ -17,7 +17,7 @@
## 代码
-```Python
+```python
class Solution:
def isPalindrome(self, x: int) -> bool:
if x < 0 or (x % 10 == 0 and x != 0):
diff --git "a/Solutions/0010. \346\255\243\345\210\231\350\241\250\350\276\276\345\274\217\345\214\271\351\205\215.md" "b/Solutions/0010. \346\255\243\345\210\231\350\241\250\350\276\276\345\274\217\345\214\271\351\205\215.md"
index 0a8c00ce..74ea1c1f 100644
--- "a/Solutions/0010. \346\255\243\345\210\231\350\241\250\350\276\276\345\274\217\345\214\271\351\205\215.md"
+++ "b/Solutions/0010. \346\255\243\345\210\231\350\241\250\350\276\276\345\274\217\345\214\271\351\205\215.md"
@@ -24,7 +24,7 @@
- 示例 1:
-```Python
+```python
输入:s = "aa", p = "a*"
输出:True
解释:因为 '*' 代表可以匹配零个或多个前面的那一个元素, 在这里前面的元素就是 'a'。因此,字符串 "aa" 可被视为 'a' 重复了一次。
@@ -32,7 +32,7 @@
- 示例 2:
-```Python
+```python
输入:s = "aa", p = "a"
输出:False
解释:"a" 无法匹配 "aa" 整个字符串。
@@ -72,7 +72,7 @@
### 思路 1:动态规划代码
-```Python
+```python
class Solution:
def isMatch(self, s: str, p: str) -> bool:
size_s, size_p = len(s), len(p)
diff --git "a/Solutions/0011. \347\233\233\346\234\200\345\244\232\346\260\264\347\232\204\345\256\271\345\231\250.md" "b/Solutions/0011. \347\233\233\346\234\200\345\244\232\346\260\264\347\232\204\345\256\271\345\231\250.md"
index 162ab008..546a234b 100644
--- "a/Solutions/0011. \347\233\233\346\234\200\345\244\232\346\260\264\347\232\204\345\256\271\345\231\250.md"
+++ "b/Solutions/0011. \347\233\233\346\234\200\345\244\232\346\260\264\347\232\204\345\256\271\345\231\250.md"
@@ -21,7 +21,7 @@

-```Python
+```python
输入:[1,8,6,2,5,4,8,3,7]
输出:49
解释:图中垂直线代表输入数组 [1,8,6,2,5,4,8,3,7]。在此情况下,容器能够容纳水(表示为蓝色部分)的最大值为 49。
@@ -44,7 +44,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def maxArea(self, height: List[int]) -> int:
left = 0
diff --git "a/Solutions/0012. \346\225\264\346\225\260\350\275\254\347\275\227\351\251\254\346\225\260\345\255\227.md" "b/Solutions/0012. \346\225\264\346\225\260\350\275\254\347\275\227\351\251\254\346\225\260\345\255\227.md"
index 108ead65..e5f74701 100644
--- "a/Solutions/0012. \346\225\264\346\225\260\350\275\254\347\275\227\351\251\254\346\225\260\345\255\227.md"
+++ "b/Solutions/0012. \346\225\264\346\225\260\350\275\254\347\275\227\351\251\254\346\225\260\345\255\227.md"
@@ -28,7 +28,7 @@
## 代码
-```Python
+```python
class Solution:
def intToRoman(self, num: int) -> str:
roman_dict = {1000:'M', 900:'CM', 500:'D', 400:'CD', 100:'C', 90:'XC', 50:'L', 40:'XL', 10:'X', 9:'IX', 5:'V', 4:'IV', 1:'I'}
diff --git "a/Solutions/0013. \347\275\227\351\251\254\346\225\260\345\255\227\350\275\254\346\225\264\346\225\260.md" "b/Solutions/0013. \347\275\227\351\251\254\346\225\260\345\255\227\350\275\254\346\225\264\346\225\260.md"
index 4cea4ecb..594537c7 100644
--- "a/Solutions/0013. \347\275\227\351\251\254\346\225\260\345\255\227\350\275\254\346\225\264\346\225\260.md"
+++ "b/Solutions/0013. \347\275\227\351\251\254\346\225\260\345\255\227\350\275\254\346\225\264\346\225\260.md"
@@ -19,7 +19,7 @@
## 代码
-```Python
+```python
class Solution:
def romanToInt(self, s: str) -> int:
nunbers = {
diff --git "a/Solutions/0014. \346\234\200\351\225\277\345\205\254\345\205\261\345\211\215\347\274\200.md" "b/Solutions/0014. \346\234\200\351\225\277\345\205\254\345\205\261\345\211\215\347\274\200.md"
index 591d1f8d..64647e7a 100644
--- "a/Solutions/0014. \346\234\200\351\225\277\345\205\254\345\205\261\345\211\215\347\274\200.md"
+++ "b/Solutions/0014. \346\234\200\351\225\277\345\205\254\345\205\261\345\211\215\347\274\200.md"
@@ -19,14 +19,14 @@
- 示例 1:
-```Python
+```python
输入:strs = ["flower","flow","flight"]
输出:"fl"
```
- 示例 2:
-```Python
+```python
输入:strs = ["dog","racecar","car"]
输出:""
解释:输入不存在公共前缀。
@@ -43,7 +43,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def longestCommonPrefix(self, strs: List[str]) -> str:
if not strs:
diff --git "a/Solutions/0015. \344\270\211\346\225\260\344\271\213\345\222\214.md" "b/Solutions/0015. \344\270\211\346\225\260\344\271\213\345\222\214.md"
index f6d5af9b..1fbcc13b 100644
--- "a/Solutions/0015. \344\270\211\346\225\260\344\271\213\345\222\214.md"
+++ "b/Solutions/0015. \344\270\211\346\225\260\344\271\213\345\222\214.md"
@@ -18,14 +18,14 @@
- 示例 1:
-```Python
+```python
输入:nums = [-1,0,1,2,-1,-4]
输出:[[-1,-1,2],[-1,0,1]]
```
- 示例 2:
-```Python
+```python
输入:nums = [0,1,1]
输出:[]
```
@@ -46,7 +46,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def threeSum(self, nums: List[int]) -> List[List[int]]:
n = len(nums)
diff --git "a/Solutions/0016. \346\234\200\346\216\245\350\277\221\347\232\204\344\270\211\346\225\260\344\271\213\345\222\214.md" "b/Solutions/0016. \346\234\200\346\216\245\350\277\221\347\232\204\344\270\211\346\225\260\344\271\213\345\222\214.md"
index 2de1d404..f80144bc 100644
--- "a/Solutions/0016. \346\234\200\346\216\245\350\277\221\347\232\204\344\270\211\346\225\260\344\271\213\345\222\214.md"
+++ "b/Solutions/0016. \346\234\200\346\216\245\350\277\221\347\232\204\344\270\211\346\225\260\344\271\213\345\222\214.md"
@@ -25,7 +25,7 @@
## 代码
-```Python
+```python
class Solution:
def threeSumClosest(self, nums: List[int], target: int) -> int:
nums.sort()
diff --git "a/Solutions/0017. \347\224\265\350\257\235\345\217\267\347\240\201\347\232\204\345\255\227\346\257\215\347\273\204\345\220\210.md" "b/Solutions/0017. \347\224\265\350\257\235\345\217\267\347\240\201\347\232\204\345\255\227\346\257\215\347\273\204\345\220\210.md"
index be10d262..f83820e5 100644
--- "a/Solutions/0017. \347\224\265\350\257\235\345\217\267\347\240\201\347\232\204\345\255\227\346\257\215\347\273\204\345\220\210.md"
+++ "b/Solutions/0017. \347\224\265\350\257\235\345\217\267\347\240\201\347\232\204\345\255\227\346\257\215\347\273\204\345\220\210.md"
@@ -20,14 +20,14 @@
- 示例 1:
-```Python
+```python
输入:digits = "23"
输出:["ad","ae","af","bd","be","bf","cd","ce","cf"]
```
- 示例 2:
-```Python
+```python
输入:digits = "2"
输出:["a","b","c"]
```
@@ -42,7 +42,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def letterCombinations(self, digits: str) -> List[str]:
if not digits:
diff --git "a/Solutions/0018. \345\233\233\346\225\260\344\271\213\345\222\214.md" "b/Solutions/0018. \345\233\233\346\225\260\344\271\213\345\222\214.md"
index 8a8e48e0..e2d57363 100644
--- "a/Solutions/0018. \345\233\233\346\225\260\344\271\213\345\222\214.md"
+++ "b/Solutions/0018. \345\233\233\346\225\260\344\271\213\345\222\214.md"
@@ -24,7 +24,7 @@
## 代码
-```Python
+```python
class Solution:
def fourSum(self, nums: List[int], target: int) -> List[List[int]]:
n = len(nums)
diff --git "a/Solutions/0019. \345\210\240\351\231\244\351\223\276\350\241\250\347\232\204\345\200\222\346\225\260\347\254\254 N \344\270\252\347\273\223\347\202\271.md" "b/Solutions/0019. \345\210\240\351\231\244\351\223\276\350\241\250\347\232\204\345\200\222\346\225\260\347\254\254 N \344\270\252\347\273\223\347\202\271.md"
index 7beb4a41..ed370ef2 100644
--- "a/Solutions/0019. \345\210\240\351\231\244\351\223\276\350\241\250\347\232\204\345\200\222\346\225\260\347\254\254 N \344\270\252\347\273\223\347\202\271.md"
+++ "b/Solutions/0019. \345\210\240\351\231\244\351\223\276\350\241\250\347\232\204\345\200\222\346\225\260\347\254\254 N \344\270\252\347\273\223\347\202\271.md"
@@ -23,14 +23,14 @@

-```Python
+```python
输入:head = [1,2,3,4,5], n = 2
输出:[1,2,3,5]
```
- 示例 2:
-```Python
+```python
输入:head = [1], n = 1
输出:[]
```
@@ -47,7 +47,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def removeNthFromEnd(self, head: ListNode, n: int) -> ListNode:
newHead = ListNode(0, head)
diff --git "a/Solutions/0020. \346\234\211\346\225\210\347\232\204\346\213\254\345\217\267.md" "b/Solutions/0020. \346\234\211\346\225\210\347\232\204\346\213\254\345\217\267.md"
index ae84fa21..cb619c9d 100644
--- "a/Solutions/0020. \346\234\211\346\225\210\347\232\204\346\213\254\345\217\267.md"
+++ "b/Solutions/0020. \346\234\211\346\225\210\347\232\204\346\213\254\345\217\267.md"
@@ -19,14 +19,14 @@
- 示例 1:
-```Python
+```python
输入:s = "()"
输出:True
```
- 示例 2:
-```Python
+```python
输入:s = "()[]{}"
输出:True
```
@@ -49,7 +49,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def isValid(self, s: str) -> bool:
if len(s) % 2 == 1:
diff --git "a/Solutions/0021. \345\220\210\345\271\266\344\270\244\344\270\252\346\234\211\345\272\217\351\223\276\350\241\250.md" "b/Solutions/0021. \345\220\210\345\271\266\344\270\244\344\270\252\346\234\211\345\272\217\351\223\276\350\241\250.md"
index db40c760..fbde2ded 100644
--- "a/Solutions/0021. \345\220\210\345\271\266\344\270\244\344\270\252\346\234\211\345\272\217\351\223\276\350\241\250.md"
+++ "b/Solutions/0021. \345\220\210\345\271\266\344\270\244\344\270\252\346\234\211\345\272\217\351\223\276\350\241\250.md"
@@ -21,14 +21,14 @@

-```Python
+```python
输入:list1 = [1,2,4], list2 = [1,3,4]
输出:[1,1,2,3,4,4]
```
- 示例 2:
-```Python
+```python
输入:list1 = [], list2 = []
输出:[]
```
@@ -47,7 +47,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def mergeTwoLists(self, list1: Optional[ListNode], list2: Optional[ListNode]) -> Optional[ListNode]:
dummy_head = ListNode(-1)
diff --git "a/Solutions/0022. \346\213\254\345\217\267\347\224\237\346\210\220.md" "b/Solutions/0022. \346\213\254\345\217\267\347\224\237\346\210\220.md"
index 2bf342a3..311e571d 100644
--- "a/Solutions/0022. \346\213\254\345\217\267\347\224\237\346\210\220.md"
+++ "b/Solutions/0022. \346\213\254\345\217\267\347\224\237\346\210\220.md"
@@ -17,14 +17,14 @@
- 示例 1:
-```Python
+```python
输入:n = 3
输出:["((()))","(()())","(())()","()(())","()()()"]
```
- 示例 2:
-```Python
+```python
输入:n = 1
输出:["()"]
```
@@ -62,7 +62,7 @@
- 递归搜索:在选择该元素的情况下,继续递归选择剩下元素。
- 撤销选择:将该元素从当前括号组合 `parenthesis` 中移除。
- ```Python
+ ```python
if symbol < n:
parenthesis.append('(')
backtrack(symbol + 1, index + 1)
@@ -79,7 +79,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def generateParenthesis(self, n: int) -> List[str]:
parentheses = [] # 存放所有括号组合
diff --git "a/Solutions/0023. \345\220\210\345\271\266 K \344\270\252\345\215\207\345\272\217\351\223\276\350\241\250.md" "b/Solutions/0023. \345\220\210\345\271\266 K \344\270\252\345\215\207\345\272\217\351\223\276\350\241\250.md"
index 6e08ad2a..88256449 100644
--- "a/Solutions/0023. \345\220\210\345\271\266 K \344\270\252\345\215\207\345\272\217\351\223\276\350\241\250.md"
+++ "b/Solutions/0023. \345\220\210\345\271\266 K \344\270\252\345\215\207\345\272\217\351\223\276\350\241\250.md"
@@ -22,7 +22,7 @@
- 示例 1:
-```Python
+```python
输入:lists = [[1,4,5],[1,3,4],[2,6]]
输出:[1,1,2,3,4,4,5,6]
解释:链表数组如下:
@@ -37,7 +37,7 @@
- 示例 2:
-```Python
+```python
输入:lists = []
输出:[]
```
@@ -50,7 +50,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def merge_sort(self, lists: List[ListNode], left: int, right: int) -> ListNode:
if left == right:
diff --git "a/Solutions/0024. \344\270\244\344\270\244\344\272\244\346\215\242\351\223\276\350\241\250\344\270\255\347\232\204\350\212\202\347\202\271.md" "b/Solutions/0024. \344\270\244\344\270\244\344\272\244\346\215\242\351\223\276\350\241\250\344\270\255\347\232\204\350\212\202\347\202\271.md"
index b99f5a2b..f30c5b43 100644
--- "a/Solutions/0024. \344\270\244\344\270\244\344\272\244\346\215\242\351\223\276\350\241\250\344\270\255\347\232\204\350\212\202\347\202\271.md"
+++ "b/Solutions/0024. \344\270\244\344\270\244\344\272\244\346\215\242\351\223\276\350\241\250\344\270\255\347\232\204\350\212\202\347\202\271.md"
@@ -21,14 +21,14 @@

-```Python
+```python
输入:head = [1,2,3,4]
输出:[2,1,4,3]
```
- 示例 2:
-```Python
+```python
输入:head = []
输出:[]
```
@@ -44,7 +44,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def swapPairs(self, head: ListNode) -> ListNode:
new_head = ListNode(0)
diff --git "a/Solutions/0025. K \344\270\252\344\270\200\347\273\204\347\277\273\350\275\254\351\223\276\350\241\250.md" "b/Solutions/0025. K \344\270\252\344\270\200\347\273\204\347\277\273\350\275\254\351\223\276\350\241\250.md"
index 00305072..b06bb2bb 100644
--- "a/Solutions/0025. K \344\270\252\344\270\200\347\273\204\347\277\273\350\275\254\351\223\276\350\241\250.md"
+++ "b/Solutions/0025. K \344\270\252\344\270\200\347\273\204\347\277\273\350\275\254\351\223\276\350\241\250.md"
@@ -21,7 +21,7 @@
- 示例 1:
-```Python
+```python
输入:head = [1,2,3,4,5], k = 2
输出:[2,1,4,3,5]
```
@@ -61,7 +61,7 @@
### 思路 1:代码
-```Python
+```python
# Definition for singly-linked list.
# class ListNode:
# def __init__(self, val=0, next=None):
diff --git "a/Solutions/0026. \345\210\240\351\231\244\346\234\211\345\272\217\346\225\260\347\273\204\344\270\255\347\232\204\351\207\215\345\244\215\351\241\271.md" "b/Solutions/0026. \345\210\240\351\231\244\346\234\211\345\272\217\346\225\260\347\273\204\344\270\255\347\232\204\351\207\215\345\244\215\351\241\271.md"
index 32f25242..0177da0b 100644
--- "a/Solutions/0026. \345\210\240\351\231\244\346\234\211\345\272\217\346\225\260\347\273\204\344\270\255\347\232\204\351\207\215\345\244\215\351\241\271.md"
+++ "b/Solutions/0026. \345\210\240\351\231\244\346\234\211\345\272\217\346\225\260\347\273\204\344\270\255\347\232\204\351\207\215\345\244\215\351\241\271.md"
@@ -17,7 +17,7 @@
- 示例 1:
-```Python
+```python
输入:nums = [1,1,2]
输出:2, nums = [1,2,_]
解释:函数应该返回新的长度 2 ,并且原数组 nums 的前两个元素被修改为 1, 2 。不需要考虑数组中超出新长度后面的元素。
@@ -25,7 +25,7 @@
- 示例 2:
-```Python
+```python
输入:nums = [0,0,1,1,1,2,2,3,3,4]
输出:5, nums = [0,1,2,3,4]
解释:函数应该返回新的长度 5 , 并且原数组 nums 的前五个元素被修改为 0, 1, 2, 3, 4 。不需要考虑数组中超出新长度后面的元素。
@@ -49,7 +49,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def removeDuplicates(self, nums: List[int]) -> int:
if len(nums) <= 1:
diff --git "a/Solutions/0027. \347\247\273\351\231\244\345\205\203\347\264\240.md" "b/Solutions/0027. \347\247\273\351\231\244\345\205\203\347\264\240.md"
index 39c1997a..65dbc1f1 100644
--- "a/Solutions/0027. \347\247\273\351\231\244\345\205\203\347\264\240.md"
+++ "b/Solutions/0027. \347\247\273\351\231\244\345\205\203\347\264\240.md"
@@ -19,7 +19,7 @@
- 示例 1:
-```Python
+```python
输入:nums = [3,2,2,3], val = 3
输出:2, nums = [2,2]
解释:函数应该返回新的长度 2, 并且 nums 中的前两个元素均为 2。你不需要考虑数组中超出新长度后面的元素。例如,函数返回的新长度为 2 ,而 nums = [2,2,3,3] 或 nums = [2,2,0,0],也会被视作正确答案。
@@ -27,7 +27,7 @@
- 示例 2:
-```Python
+```python
输入:nums = [0,1,2,2,3,0,4,2], val = 2
输出:5, nums = [0,1,4,0,3]
解释:函数应该返回新的长度 5, 并且 nums 中的前五个元素为 0, 1, 3, 0, 4。注意这五个元素可为任意顺序。你不需要考虑数组中超出新长度后面的元素。
@@ -44,7 +44,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def removeElement(self, nums: List[int], val: int) -> int:
slow = 0
diff --git "a/Solutions/0028. \346\211\276\345\207\272\345\255\227\347\254\246\344\270\262\344\270\255\347\254\254\344\270\200\344\270\252\345\214\271\351\205\215\351\241\271\347\232\204\344\270\213\346\240\207.md" "b/Solutions/0028. \346\211\276\345\207\272\345\255\227\347\254\246\344\270\262\344\270\255\347\254\254\344\270\200\344\270\252\345\214\271\351\205\215\351\241\271\347\232\204\344\270\213\346\240\207.md"
index 845d305d..0209e66a 100644
--- "a/Solutions/0028. \346\211\276\345\207\272\345\255\227\347\254\246\344\270\262\344\270\255\347\254\254\344\270\200\344\270\252\345\214\271\351\205\215\351\241\271\347\232\204\344\270\213\346\240\207.md"
+++ "b/Solutions/0028. \346\211\276\345\207\272\345\255\227\347\254\246\344\270\262\344\270\255\347\254\254\344\270\200\344\270\252\345\214\271\351\205\215\351\241\271\347\232\204\344\270\213\346\240\207.md"
@@ -19,7 +19,7 @@
- 示例 1:
-```Python
+```python
输入:haystack = "hello", needle = "ll"
输出:2
解释:"sad" 在下标 0 和 6 处匹配。第一个匹配项的下标是 0 ,所以返回 0 。
@@ -27,7 +27,7 @@
- 示例 2:
-```Python
+```python
输入:haystack = "leetcode", needle = "leeto"
输出:-1
解释:"leeto" 没有在 "leetcode" 中出现,所以返回 -1 。
@@ -51,7 +51,7 @@ BF 算法具体步骤如下:
### 思路 1:代码
-```Python
+```python
class Solution:
def strStr(self, haystack: str, needle: str) -> int:
i = 0
@@ -96,7 +96,7 @@ RK 算法具体步骤如下:
### 思路 2:代码
-```Python
+```python
class Solution:
def strStr(self, haystack: str, needle: str) -> int:
def rabinKarp(T: str, p: str) -> int:
@@ -139,7 +139,7 @@ KMP 算法具体步骤如下:
### 思路 3:代码
-```Python
+```python
class Solution:
def strStr(self, haystack: str, needle: str) -> int:
# KMP 匹配算法,T 为文本串,p 为模式串
@@ -206,7 +206,7 @@ BM 算法具体步骤如下:
### 思路 4:代码
-```Python
+```python
class Solution:
def strStr(self, haystack: str, needle: str) -> int:
def boyerMoore(T: str, p: str) -> int:
@@ -288,7 +288,7 @@ Horspool 算法具体步骤如下:
### 思路 5:代码
-```Python
+```python
class Solution:
def strStr(self, haystack: str, needle: str) -> int:
def horspool(T: str, p: str) -> int:
@@ -341,7 +341,7 @@ Sunday 算法具体步骤如下:
### 思路 6:代码
-```Python
+```python
class Solution:
def strStr(self, haystack: str, needle: str) -> int:
# sunday 算法,T 为文本串,p 为模式串
diff --git "a/Solutions/0029. \344\270\244\346\225\260\347\233\270\351\231\244.md" "b/Solutions/0029. \344\270\244\346\225\260\347\233\270\351\231\244.md"
index d1d3f014..cf0c3994 100644
--- "a/Solutions/0029. \344\270\244\346\225\260\347\233\270\351\231\244.md"
+++ "b/Solutions/0029. \344\270\244\346\225\260\347\233\270\351\231\244.md"
@@ -22,7 +22,7 @@
## 代码
-```Python
+```python
class Solution:
def divide(self, dividend: int, divisor: int) -> int:
MIN_INT, MAX_INT = -2147483648, 2147483647
diff --git "a/Solutions/0032. \346\234\200\351\225\277\346\234\211\346\225\210\346\213\254\345\217\267.md" "b/Solutions/0032. \346\234\200\351\225\277\346\234\211\346\225\210\346\213\254\345\217\267.md"
index f9aa4478..3ecd5322 100644
--- "a/Solutions/0032. \346\234\200\351\225\277\346\234\211\346\225\210\346\213\254\345\217\267.md"
+++ "b/Solutions/0032. \346\234\200\351\225\277\346\234\211\346\225\210\346\213\254\345\217\267.md"
@@ -18,7 +18,7 @@
- 示例 1:
-```Python
+```python
输入:s = "(()"
输出:2
解释:最长有效括号子串是 "()"
@@ -26,7 +26,7 @@
- 示例 2:
-```Python
+```python
输入:s = ")()())"
输出:4
解释:最长有效括号子串是 "()()"
@@ -66,7 +66,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def longestValidParentheses(self, s: str) -> int:
dp = [0 for _ in range(len(s))]
@@ -113,7 +113,7 @@ class Solution:
### 思路 2:代码
-```Python
+```python
class Solution:
def longestValidParentheses(self, s: str) -> int:
stack = [-1]
diff --git "a/Solutions/0033. \346\220\234\347\264\242\346\227\213\350\275\254\346\216\222\345\272\217\346\225\260\347\273\204.md" "b/Solutions/0033. \346\220\234\347\264\242\346\227\213\350\275\254\346\216\222\345\272\217\346\225\260\347\273\204.md"
index fb72a93e..fa4e55a4 100644
--- "a/Solutions/0033. \346\220\234\347\264\242\346\227\213\350\275\254\346\216\222\345\272\217\346\225\260\347\273\204.md"
+++ "b/Solutions/0033. \346\220\234\347\264\242\346\227\213\350\275\254\346\216\222\345\272\217\346\225\260\347\273\204.md"
@@ -17,14 +17,14 @@
- 示例 1:
-```Python
+```python
输入:nums = [4,5,6,7,0,1,2], target = 0
输出:4
```
- 示例 2:
-```Python
+```python
输入:nums = [4,5,6,7,0,1,2], target = 3
输出:-1
```
@@ -35,7 +35,7 @@
原本为升序排列的数组 `nums` 经过「旋转」之后,会有两种情况,第一种就是原先的升序序列,另一种是两段升序的序列。
-```Python
+```python
*
*
*
@@ -44,7 +44,7 @@
*
```
-```Python
+```python
*
*
*
@@ -74,7 +74,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def search(self, nums: List[int], target: int) -> int:
left = 0
diff --git "a/Solutions/0034. \345\234\250\346\216\222\345\272\217\346\225\260\347\273\204\344\270\255\346\237\245\346\211\276\345\205\203\347\264\240\347\232\204\347\254\254\344\270\200\344\270\252\345\222\214\346\234\200\345\220\216\344\270\200\344\270\252\344\275\215\347\275\256.md" "b/Solutions/0034. \345\234\250\346\216\222\345\272\217\346\225\260\347\273\204\344\270\255\346\237\245\346\211\276\345\205\203\347\264\240\347\232\204\347\254\254\344\270\200\344\270\252\345\222\214\346\234\200\345\220\216\344\270\200\344\270\252\344\275\215\347\275\256.md"
index 1dbc882d..7a8ed441 100644
--- "a/Solutions/0034. \345\234\250\346\216\222\345\272\217\346\225\260\347\273\204\344\270\255\346\237\245\346\211\276\345\205\203\347\264\240\347\232\204\347\254\254\344\270\200\344\270\252\345\222\214\346\234\200\345\220\216\344\270\200\344\270\252\344\275\215\347\275\256.md"
+++ "b/Solutions/0034. \345\234\250\346\216\222\345\272\217\346\225\260\347\273\204\344\270\255\346\237\245\346\211\276\345\205\203\347\264\240\347\232\204\347\254\254\344\270\200\344\270\252\345\222\214\346\234\200\345\220\216\344\270\200\344\270\252\344\275\215\347\275\256.md"
@@ -17,14 +17,14 @@
- 示例 1:
-```Python
+```python
输入:nums = [5,7,7,8,8,10], target = 8
输出:[3,4]
```
- 示例 2:
-```Python
+```python
输入:nums = [5,7,7,8,8,10], target = 6
输出:[-1,-1]
```
@@ -39,7 +39,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def searchRange(self, nums: List[int], target: int) -> List[int]:
ans = [-1, -1]
diff --git "a/Solutions/0035. \346\220\234\347\264\242\346\217\222\345\205\245\344\275\215\347\275\256.md" "b/Solutions/0035. \346\220\234\347\264\242\346\217\222\345\205\245\344\275\215\347\275\256.md"
index a6493103..6f2dce70 100644
--- "a/Solutions/0035. \346\220\234\347\264\242\346\217\222\345\205\245\344\275\215\347\275\256.md"
+++ "b/Solutions/0035. \346\220\234\347\264\242\346\217\222\345\205\245\344\275\215\347\275\256.md"
@@ -20,7 +20,7 @@
- 示例 1:
-```Python
+```python
输入:nums = [1,3,5,6], target = 5
输出:2
```
@@ -41,7 +41,7 @@
### 思路 1:二分查找代码
-```Python
+```python
class Solution:
def searchInsert(self, nums: List[int], target: int) -> int:
size = len(nums)
diff --git "a/Solutions/0036. \346\234\211\346\225\210\347\232\204\346\225\260\347\213\254.md" "b/Solutions/0036. \346\234\211\346\225\210\347\232\204\346\225\260\347\213\254.md"
index 3ecf18a8..77b17741 100644
--- "a/Solutions/0036. \346\234\211\346\225\210\347\232\204\346\225\260\347\213\254.md"
+++ "b/Solutions/0036. \346\234\211\346\225\210\347\232\204\346\225\260\347\213\254.md"
@@ -27,7 +27,7 @@

-```Python
+```python
输入:board =
[["5","3",".",".","7",".",".",".","."]
,["6",".",".","1","9","5",".",".","."]
@@ -53,7 +53,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def isValidSudoku(self, board: List[List[str]]) -> bool:
rows_map = [dict() for _ in range(9)]
diff --git "a/Solutions/0037. \350\247\243\346\225\260\347\213\254.md" "b/Solutions/0037. \350\247\243\346\225\260\347\213\254.md"
index 581eb279..f103e6f0 100644
--- "a/Solutions/0037. \350\247\243\346\225\260\347\213\254.md"
+++ "b/Solutions/0037. \350\247\243\346\225\260\347\213\254.md"
@@ -29,7 +29,7 @@
## 代码
-```Python
+```python
class Solution:
def backtrack(self, board: List[List[str]]):
for i in range(len(board)):
diff --git "a/Solutions/0038. \345\244\226\350\247\202\346\225\260\345\210\227.md" "b/Solutions/0038. \345\244\226\350\247\202\346\225\260\345\210\227.md"
index 28e87309..89ead2f6 100644
--- "a/Solutions/0038. \345\244\226\350\247\202\346\225\260\345\210\227.md"
+++ "b/Solutions/0038. \345\244\226\350\247\202\346\225\260\345\210\227.md"
@@ -27,7 +27,7 @@
## 代码
-```Python
+```python
class Solution:
def countAndSay(self, n: int) -> str:
ans = "1"
diff --git "a/Solutions/0039. \347\273\204\345\220\210\346\200\273\345\222\214.md" "b/Solutions/0039. \347\273\204\345\220\210\346\200\273\345\222\214.md"
index ed9cc911..7f0608fc 100644
--- "a/Solutions/0039. \347\273\204\345\220\210\346\200\273\345\222\214.md"
+++ "b/Solutions/0039. \347\273\204\345\220\210\346\200\273\345\222\214.md"
@@ -22,7 +22,7 @@
- 示例 1:
-```Python
+```python
输入:candidates = [2,3,6,7], target = 7
输出:[[2,2,3],[7]]
解释:
@@ -33,7 +33,7 @@
- 示例 2:
-```Python
+```python
输入: candidates = [2,3,5], target = 8
输出: [[2,2,2,2],[2,3,3],[3,5]]
```
@@ -74,7 +74,7 @@
- 递归搜索:在选择该元素的情况下,继续递归选择剩下元素。
- 撤销选择:将该元素从当前结果数组 `path` 中移除。
- ```Python
+ ```python
for i in range(start_index, len(candidates)):
if total + candidates[i] > target:
break
@@ -92,7 +92,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def combinationSum(self, candidates: List[int], target: int) -> List[List[int]]:
res = []
diff --git "a/Solutions/0040. \347\273\204\345\220\210\346\200\273\345\222\214 II.md" "b/Solutions/0040. \347\273\204\345\220\210\346\200\273\345\222\214 II.md"
index 84b3af6b..0f9b1024 100644
--- "a/Solutions/0040. \347\273\204\345\220\210\346\200\273\345\222\214 II.md"
+++ "b/Solutions/0040. \347\273\204\345\220\210\346\200\273\345\222\214 II.md"
@@ -19,7 +19,7 @@
- 示例 1:
-```Python
+```python
输入: candidates = [10,1,2,7,6,1,5], target = 8,
输出:
[
@@ -32,7 +32,7 @@
- 示例 2:
-```Python
+```python
输入: candidates = [2,5,2,1,2], target = 5,
输出:
[
@@ -51,7 +51,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
res = []
path = []
diff --git "a/Solutions/0041. \347\274\272\345\244\261\347\232\204\347\254\254\344\270\200\344\270\252\346\255\243\346\225\260.md" "b/Solutions/0041. \347\274\272\345\244\261\347\232\204\347\254\254\344\270\200\344\270\252\346\255\243\346\225\260.md"
index d1ecd83d..04695407 100644
--- "a/Solutions/0041. \347\274\272\345\244\261\347\232\204\347\254\254\344\270\200\344\270\252\346\255\243\346\225\260.md"
+++ "b/Solutions/0041. \347\274\272\345\244\261\347\232\204\347\254\254\344\270\200\344\270\252\346\255\243\346\225\260.md"
@@ -19,14 +19,14 @@
- 示例 1:
-```Python
+```python
输入:nums = [1,2,0]
输出:3
```
- 示例 2:
-```Python
+```python
输入:nums = [3,4,-1,1]
输出:2
```
@@ -46,7 +46,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def firstMissingPositive(self, nums: List[int]) -> int:
size = len(nums)
diff --git "a/Solutions/0042. \346\216\245\351\233\250\346\260\264.md" "b/Solutions/0042. \346\216\245\351\233\250\346\260\264.md"
index 5ab5557d..e8605682 100644
--- "a/Solutions/0042. \346\216\245\351\233\250\346\260\264.md"
+++ "b/Solutions/0042. \346\216\245\351\233\250\346\260\264.md"
@@ -21,7 +21,7 @@

-```Python
+```python
输入:height = [0,1,0,2,1,0,1,3,2,1,2,1]
输出:6
解释:上面是由数组 [0,1,0,2,1,0,1,3,2,1,2,1] 表示的高度图,在这种情况下,可以接 6 个单位的雨水(蓝色部分表示雨水)。
@@ -29,7 +29,7 @@
- 示例 2:
-```Python
+```python
输入:height = [4,2,0,3,2,5]
输出:9
```
@@ -48,7 +48,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def trap(self, height: List[int]) -> int:
ans = 0
diff --git "a/Solutions/0043. \345\255\227\347\254\246\344\270\262\347\233\270\344\271\230.md" "b/Solutions/0043. \345\255\227\347\254\246\344\270\262\347\233\270\344\271\230.md"
index a81312c0..49d67020 100644
--- "a/Solutions/0043. \345\255\227\347\254\246\344\270\262\347\233\270\344\271\230.md"
+++ "b/Solutions/0043. \345\255\227\347\254\246\344\270\262\347\233\270\344\271\230.md"
@@ -20,14 +20,14 @@
- 示例 1:
-```Python
+```python
输入: num1 = "2", num2 = "3"
输出: "6"
```
- 示例 2:
-```Python
+```python
输入: num1 = "123", num2 = "456"
输出: "56088"
```
@@ -47,7 +47,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def multiply(self, num1: str, num2: str) -> str:
if num1 == "0" or num2 == "0":
diff --git "a/Solutions/0044. \351\200\232\351\205\215\347\254\246\345\214\271\351\205\215.md" "b/Solutions/0044. \351\200\232\351\205\215\347\254\246\345\214\271\351\205\215.md"
index 9aa57f8d..a4869773 100644
--- "a/Solutions/0044. \351\200\232\351\205\215\347\254\246\345\214\271\351\205\215.md"
+++ "b/Solutions/0044. \351\200\232\351\205\215\347\254\246\345\214\271\351\205\215.md"
@@ -21,7 +21,7 @@
- 示例 1:
-```Python
+```python
输入:s = "aa" p = "a"
输出:False
解释:"a" 无法匹配 "aa" 整个字符串。
@@ -29,7 +29,7 @@
- 示例 2:
-```Python
+```python
输入:s = "aa" p = "*"
输出:True
解释:'*' 可以匹配任意字符串。
@@ -70,7 +70,7 @@ $dp[i][j] = \begin{cases} dp[i - 1][j - 1] & s[i - 1] == p[j - 1] \or p[j - 1] =
### 思路 1:动态规划代码
-```Python
+```python
class Solution:
def isMatch(self, s: str, p: str) -> bool:
size_s, size_p = len(s), len(p)
diff --git "a/Solutions/0045. \350\267\263\350\267\203\346\270\270\346\210\217 II.md" "b/Solutions/0045. \350\267\263\350\267\203\346\270\270\346\210\217 II.md"
index ba0158fa..54883b42 100644
--- "a/Solutions/0045. \350\267\263\350\267\203\346\270\270\346\210\217 II.md"
+++ "b/Solutions/0045. \350\267\263\350\267\203\346\270\270\346\210\217 II.md"
@@ -18,7 +18,7 @@
- 示例 1:
-```Python
+```python
输入:nums = [2,3,1,1,4]
输出:2
解释:跳到最后一个位置的最小跳跃数是 2。从下标为 0 跳到下标为 1 的位置,跳 1 步,然后跳 3 步到达数组的最后一个位置。
@@ -52,7 +52,7 @@
### 思路 1:动态规划(超时)代码
-```Python
+```python
class Solution:
def jump(self, nums: List[int]) -> int:
size = len(nums)
@@ -90,7 +90,7 @@ class Solution:
### 思路 2:动态规划 + 贪心代码
-```Python
+```python
class Solution:
def jump(self, nums: List[int]) -> int:
size = len(nums)
@@ -129,7 +129,7 @@ class Solution:
### 思路 2:贪心算法代码
-```Python
+```python
class Solution:
def jump(self, nums: List[int]) -> int:
end, max_pos = 0, 0
diff --git "a/Solutions/0046. \345\205\250\346\216\222\345\210\227.md" "b/Solutions/0046. \345\205\250\346\216\222\345\210\227.md"
index 044c00b9..9915462c 100644
--- "a/Solutions/0046. \345\205\250\346\216\222\345\210\227.md"
+++ "b/Solutions/0046. \345\205\250\346\216\222\345\210\227.md"
@@ -19,14 +19,14 @@
- 示例 1:
-```Python
+```python
输入:nums = [1,2,3]
输出:[[1,2,3],[1,3,2],[2,1,3],[2,3,1],[3,1,2],[3,2,1]]
```
- 示例 2:
-```Python
+```python
输入:nums = [0,1]
输出:[[0,1],[1,0]]
```
@@ -58,7 +58,7 @@
- 递归搜索:在选择该元素的情况下,继续递归选择剩下元素。
- 撤销选择:将该元素从当前结果数组 `path` 中移除。
- ```Python
+ ```python
for i in range(len(nums)): # 枚举可选元素列表
if nums[i] not in path: # 从当前路径中没有出现的数字中选择
path.append(nums[i]) # 选择元素
@@ -71,7 +71,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def permute(self, nums: List[int]) -> List[List[int]]:
res = [] # 存放所有符合条件结果的集合
diff --git "a/Solutions/0047. \345\205\250\346\216\222\345\210\227 II.md" "b/Solutions/0047. \345\205\250\346\216\222\345\210\227 II.md"
index cfb48c60..d67b5dea 100644
--- "a/Solutions/0047. \345\205\250\346\216\222\345\210\227 II.md"
+++ "b/Solutions/0047. \345\205\250\346\216\222\345\210\227 II.md"
@@ -18,14 +18,14 @@
- 示例 1:
-```Python
+```python
输入:nums = [1,1,2]
输出:[[1,1,2],[1,2,1],[2,1,1]]
```
- 示例 2:
-```Python
+```python
输入:nums = [1,2,3]
输出:[[1,2,3],[1,3,2],[2,1,3],[2,3,1],[3,1,2],[3,2,1]]
```
@@ -46,7 +46,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
res = []
path = []
diff --git "a/Solutions/0048. \346\227\213\350\275\254\345\233\276\345\203\217.md" "b/Solutions/0048. \346\227\213\350\275\254\345\233\276\345\203\217.md"
index a2343d10..632185cf 100644
--- "a/Solutions/0048. \346\227\213\350\275\254\345\233\276\345\203\217.md"
+++ "b/Solutions/0048. \346\227\213\350\275\254\345\233\276\345\203\217.md"
@@ -22,7 +22,7 @@

-```Python
+```python
输入:matrix = [[1,2,3],[4,5,6],[7,8,9]]
输出:[[7,4,1],[8,5,2],[9,6,3]]
```
@@ -31,7 +31,7 @@

-```Python
+```python
输入:matrix = [[5,1,9,11],[2,4,8,10],[13,3,6,7],[15,14,12,16]]
输出:[[15,13,2,5],[14,3,4,1],[12,6,8,9],[16,7,10,11]]
```
@@ -54,7 +54,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def rotate(self, matrix: List[List[int]]) -> None:
n = len(matrix)
@@ -75,7 +75,7 @@ class Solution:
### 思路 2:代码
-```Python
+```python
def rotate(self, matrix: List[List[int]]) -> None:
n = len(matrix)
diff --git "a/Solutions/0049. \345\255\227\346\257\215\345\274\202\344\275\215\350\257\215\345\210\206\347\273\204.md" "b/Solutions/0049. \345\255\227\346\257\215\345\274\202\344\275\215\350\257\215\345\210\206\347\273\204.md"
index c0a2c196..c9546760 100644
--- "a/Solutions/0049. \345\255\227\346\257\215\345\274\202\344\275\215\350\257\215\345\210\206\347\273\204.md"
+++ "b/Solutions/0049. \345\255\227\346\257\215\345\274\202\344\275\215\350\257\215\345\210\206\347\273\204.md"
@@ -15,7 +15,7 @@
## 代码
-```Python
+```python
class Solution:
def groupAnagrams(self, strs: List[str]) -> List[List[str]]:
str_dict = dict()
diff --git a/Solutions/0050. Pow(x, n).md b/Solutions/0050. Pow(x, n).md
index d4a58412..e46a51e3 100644
--- a/Solutions/0050. Pow(x, n).md
+++ b/Solutions/0050. Pow(x, n).md
@@ -20,14 +20,14 @@
- 示例 1:
-```Python
+```python
输入:x = 2.00000, n = 10
输出:1024.00000
```
- 示例 2:
-```Python
+```python
输入:x = 2.00000, n = -2
输出:0.25000
解释:2-2 = 1/22 = 1/4 = 0.25
@@ -56,7 +56,7 @@ $x^{(n / 2)}$ 或 $x^{(n - 1) / 2}$ 又可以继续向下递归划分。
### 思路 1:代码
-```Python
+```python
class Solution:
def myPow(self, x: float, n: int) -> float:
if x == 0.0:
diff --git "a/Solutions/0051. N \347\232\207\345\220\216.md" "b/Solutions/0051. N \347\232\207\345\220\216.md"
index 7ed4ee59..c0cc836c 100644
--- "a/Solutions/0051. N \347\232\207\345\220\216.md"
+++ "b/Solutions/0051. N \347\232\207\345\220\216.md"
@@ -19,7 +19,7 @@
- 示例 1:
-```Python
+```python
输入:n = 4
输出:[[".Q..","...Q","Q...","..Q."],["..Q.","Q...","...Q",".Q.."]]
解释:如下图所示,4 皇后问题存在 2 个不同的解法。
@@ -61,7 +61,7 @@
- 递归搜索:在该位置放置皇后的情况下,继续递归考虑下一行。
- 撤销选择:将棋盘上 `row, col` 位置设置为 `.`。
- ```Python
+ ```python
# 判断当前位置 row, col 是否与之前放置的皇后发生冲突
def isValid(self, n: int, row: int, col: int, chessboard: List[List[str]]):
for i in range(row):
@@ -84,7 +84,7 @@
return True
```
- ```Python
+ ```python
for col in range(n): # 枚举可放置皇后的列
if self.isValid(n, row, col, chessboard): # 如果该位置与之前放置的皇后不发生冲突
chessboard[row][col] = 'Q' # 选择 row, col 位置放置皇后
@@ -98,7 +98,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
res = []
def backtrack(self, n: int, row: int, chessboard: List[List[str]]):
diff --git "a/Solutions/0052. N \347\232\207\345\220\216 II.md" "b/Solutions/0052. N \347\232\207\345\220\216 II.md"
index 7e15956a..9dbdb452 100644
--- "a/Solutions/0052. N \347\232\207\345\220\216 II.md"
+++ "b/Solutions/0052. N \347\232\207\345\220\216 II.md"
@@ -19,7 +19,7 @@
- 示例 1:
-```Python
+```python
输入:n = 4
输出:2
解释:如下图所示,4 皇后问题存在两个不同的解法。
@@ -65,7 +65,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
# 判断当前位置 row, col 是否与之前放置的皇后发生冲突
def isValid(self, n: int, row: int, col: int, chessboard: List[List[str]]):
diff --git "a/Solutions/0053. \346\234\200\345\244\247\345\255\220\346\225\260\347\273\204\345\222\214.md" "b/Solutions/0053. \346\234\200\345\244\247\345\255\220\346\225\260\347\273\204\345\222\214.md"
index 669ed7f4..30072c86 100644
--- "a/Solutions/0053. \346\234\200\345\244\247\345\255\220\346\225\260\347\273\204\345\222\214.md"
+++ "b/Solutions/0053. \346\234\200\345\244\247\345\255\220\346\225\260\347\273\204\345\222\214.md"
@@ -19,7 +19,7 @@
- 示例 1:
-```Python
+```python
输入:nums = [-2,1,-3,4,-1,2,1,-5,4]
输出:6
解释:连续子数组 [4,-1,2,1] 的和最大,为 6。
@@ -27,7 +27,7 @@
- 示例 2:
-```Python
+```python
输入:nums = [1]
输出:1
```
@@ -65,7 +65,7 @@ $dp[i] = \begin{cases} nums[i], & dp[i - 1] < 0 \cr dp[i - 1] + nums[i] & dp[i
### 思路 1:代码
-```Python
+```python
class Solution:
def maxSubArray(self, nums: List[int]) -> int:
size = len(nums)
@@ -91,7 +91,7 @@ class Solution:
### 思路 2:代码
-```Python
+```python
class Solution:
def maxSubArray(self, nums: List[int]) -> int:
size = len(nums)
@@ -131,7 +131,7 @@ class Solution:
### 思路 3:代码
-```Python
+```python
class Solution:
def maxSubArray(self, nums: List[int]) -> int:
def max_sub_array(low, high):
diff --git "a/Solutions/0054. \350\236\272\346\227\213\347\237\251\351\230\265.md" "b/Solutions/0054. \350\236\272\346\227\213\347\237\251\351\230\265.md"
index 1f1dcb6a..d7ceef93 100644
--- "a/Solutions/0054. \350\236\272\346\227\213\347\237\251\351\230\265.md"
+++ "b/Solutions/0054. \350\236\272\346\227\213\347\237\251\351\230\265.md"
@@ -22,7 +22,7 @@

-```Python
+```python
输入:matrix = [[1,2,3],[4,5,6],[7,8,9]]
输出:[1,2,3,6,9,8,7,4,5]
```
@@ -31,7 +31,7 @@

-```Python
+```python
输入:matrix = [[1,2,3,4],[5,6,7,8],[9,10,11,12]]
输出:[1,2,3,4,8,12,11,10,9,5,6,7]
```
@@ -47,7 +47,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def spiralOrder(self, matrix: List[List[int]]) -> List[int]:
up, down, left, right = 0, len(matrix)-1, 0, len(matrix[0])-1
diff --git "a/Solutions/0055. \350\267\263\350\267\203\346\270\270\346\210\217.md" "b/Solutions/0055. \350\267\263\350\267\203\346\270\270\346\210\217.md"
index fa5b13c1..544d7202 100644
--- "a/Solutions/0055. \350\267\263\350\267\203\346\270\270\346\210\217.md"
+++ "b/Solutions/0055. \350\267\263\350\267\203\346\270\270\346\210\217.md"
@@ -18,7 +18,7 @@
- 示例 1:
-```Python
+```python
输入:nums = [2,3,1,1,4]
输出:true
解释:可以先跳 1 步,从下标 0 到达下标 1, 然后再从下标 1 跳 3 步到达最后一个下标。
@@ -26,7 +26,7 @@
- 示例 2:
-```Python
+```python
输入:nums = [3,2,1,0,4]
输出:false
解释:无论怎样,总会到达下标为 3 的位置。但该下标的最大跳跃长度是 0 , 所以永远不可能到达最后一个下标。
@@ -47,7 +47,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def canJump(self, nums: List[int]) -> bool:
size = len(nums)
@@ -89,7 +89,7 @@ class Solution:
### 思路 2:代码
-```Python
+```python
class Solution:
def canJump(self, nums: List[int]) -> bool:
size = len(nums)
diff --git "a/Solutions/0056. \345\220\210\345\271\266\345\214\272\351\227\264.md" "b/Solutions/0056. \345\220\210\345\271\266\345\214\272\351\227\264.md"
index 97b945b4..86d5d8fb 100644
--- "a/Solutions/0056. \345\220\210\345\271\266\345\214\272\351\227\264.md"
+++ "b/Solutions/0056. \345\220\210\345\271\266\345\214\272\351\227\264.md"
@@ -19,7 +19,7 @@
- 示例 1:
-```Python
+```python
输入:intervals = [[1,3],[2,6],[8,10],[15,18]]
输出:[[1,6],[8,10],[15,18]]
解释:区间 [1,3] 和 [2,6] 重叠, 将它们合并为 [1,6].
@@ -27,7 +27,7 @@
- 示例 2:
-```Python
+```python
输入:intervals = [[1,4],[4,5]]
输出:[[1,5]]
解释:区间 [1,4] 和 [4,5] 可被视为重叠区间。
@@ -47,7 +47,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def merge(self, intervals: List[List[int]]) -> List[List[int]]:
intervals.sort(key=lambda x: x[0])
diff --git "a/Solutions/0058. \346\234\200\345\220\216\344\270\200\344\270\252\345\215\225\350\257\215\347\232\204\351\225\277\345\272\246.md" "b/Solutions/0058. \346\234\200\345\220\216\344\270\200\344\270\252\345\215\225\350\257\215\347\232\204\351\225\277\345\272\246.md"
index 12f1865f..2d241ba4 100644
--- "a/Solutions/0058. \346\234\200\345\220\216\344\270\200\344\270\252\345\215\225\350\257\215\347\232\204\351\225\277\345\272\246.md"
+++ "b/Solutions/0058. \346\234\200\345\220\216\344\270\200\344\270\252\345\215\225\350\257\215\347\232\204\351\225\277\345\272\246.md"
@@ -15,7 +15,7 @@
## 代码
-```Python
+```python
class Solution:
def lengthOfLastWord(self, s: str) -> int:
ans = 0
diff --git "a/Solutions/0059. \350\236\272\346\227\213\347\237\251\351\230\265 II.md" "b/Solutions/0059. \350\236\272\346\227\213\347\237\251\351\230\265 II.md"
index 188231b2..8f98d159 100644
--- "a/Solutions/0059. \350\236\272\346\227\213\347\237\251\351\230\265 II.md"
+++ "b/Solutions/0059. \350\236\272\346\227\213\347\237\251\351\230\265 II.md"
@@ -17,7 +17,7 @@
## 代码
-```Python
+```python
class Solution:
def generateMatrix(self, n: int) -> List[List[int]]:
matrix = [[0 for _ in range(n)] for _ in range(n)]
diff --git "a/Solutions/0061. \346\227\213\350\275\254\351\223\276\350\241\250.md" "b/Solutions/0061. \346\227\213\350\275\254\351\223\276\350\241\250.md"
index 4348da9a..4e9f3a98 100644
--- "a/Solutions/0061. \346\227\213\350\275\254\351\223\276\350\241\250.md"
+++ "b/Solutions/0061. \346\227\213\350\275\254\351\223\276\350\241\250.md"
@@ -17,7 +17,7 @@
## 代码
-```Python
+```python
class Solution:
def rotateRight(self, head: ListNode, k: int) -> ListNode:
if k == 0 or not head or not head.next:
diff --git "a/Solutions/0062. \344\270\215\345\220\214\350\267\257\345\276\204.md" "b/Solutions/0062. \344\270\215\345\220\214\350\267\257\345\276\204.md"
index 5baee92f..b9e4fde3 100644
--- "a/Solutions/0062. \344\270\215\345\220\214\350\267\257\345\276\204.md"
+++ "b/Solutions/0062. \344\270\215\345\220\214\350\267\257\345\276\204.md"
@@ -18,7 +18,7 @@
- 示例 1:
-```Python
+```python
输入:m = 3, n = 7
输出:28
```
@@ -27,7 +27,7 @@
- 示例 2:
-```Python
+```python
输入:m = 3, n = 2
输出:3
解释:
@@ -65,7 +65,7 @@
### 思路 1:动态规划代码
-```Python
+```python
class Solution:
def uniquePaths(self, m: int, n: int) -> int:
dp = [[0 for _ in range(n)] for _ in range(m)]
diff --git "a/Solutions/0063. \344\270\215\345\220\214\350\267\257\345\276\204 II.md" "b/Solutions/0063. \344\270\215\345\220\214\350\267\257\345\276\204 II.md"
index 9beb7351..2ab7c21d 100644
--- "a/Solutions/0063. \344\270\215\345\220\214\350\267\257\345\276\204 II.md"
+++ "b/Solutions/0063. \344\270\215\345\220\214\350\267\257\345\276\204 II.md"
@@ -24,7 +24,7 @@

-```Python
+```python
输入:obstacleGrid = [[0,0,0],[0,1,0],[0,0,0]]
输出:2
解释:3x3 网格的正中间有一个障碍物。
@@ -37,7 +37,7 @@

-```Python
+```python
输入:obstacleGrid = [[0,1],[0,0]]
输出:1
```
@@ -68,7 +68,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def uniquePathsWithObstacles(self, obstacleGrid: List[List[int]]) -> int:
m = len(obstacleGrid)
diff --git "a/Solutions/0064. \346\234\200\345\260\217\350\267\257\345\276\204\345\222\214.md" "b/Solutions/0064. \346\234\200\345\260\217\350\267\257\345\276\204\345\222\214.md"
index f9960893..338958c7 100644
--- "a/Solutions/0064. \346\234\200\345\260\217\350\267\257\345\276\204\345\222\214.md"
+++ "b/Solutions/0064. \346\234\200\345\260\217\350\267\257\345\276\204\345\222\214.md"
@@ -23,7 +23,7 @@

-```Python
+```python
输入:grid = [[1,3,1],[1,5,1],[4,2,1]]
输出:7
解释:因为路径 1→3→1→1→1 的总和最小。
@@ -31,7 +31,7 @@
- 示例 2:
-```Python
+```python
输入:grid = [[1,2,3],[4,5,6]]
输出:12
```
@@ -66,7 +66,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def minPathSum(self, grid: List[List[int]]) -> int:
rows, cols = len(grid), len(grid[0])
diff --git "a/Solutions/0066. \345\212\240\344\270\200.md" "b/Solutions/0066. \345\212\240\344\270\200.md"
index 01567690..3d8beb6a 100644
--- "a/Solutions/0066. \345\212\240\344\270\200.md"
+++ "b/Solutions/0066. \345\212\240\344\270\200.md"
@@ -18,7 +18,7 @@
- 示例 1:
-```Python
+```python
输入:digits = [1,2,3]
输出:[1,2,4]
解释:输入数组表示数字 123,加 1 之后为 124。
@@ -42,7 +42,7 @@
### 思路 1:代码
-```Python
+```python
def plusOne(self, digits: List[int]) -> List[int]:
digits = [0] + digits
digits[len(digits) - 1] += 1
diff --git "a/Solutions/0067. \344\272\214\350\277\233\345\210\266\346\261\202\345\222\214.md" "b/Solutions/0067. \344\272\214\350\277\233\345\210\266\346\261\202\345\222\214.md"
index 11cae54b..ccdc4fdc 100644
--- "a/Solutions/0067. \344\272\214\350\277\233\345\210\266\346\261\202\345\222\214.md"
+++ "b/Solutions/0067. \344\272\214\350\277\233\345\210\266\346\261\202\345\222\214.md"
@@ -29,7 +29,7 @@
## 代码
-```Python
+```python
class Solution:
def addBinary(self, a: str, b: str) -> str:
x = int(a, 2)
diff --git "a/Solutions/0069. x \347\232\204\345\271\263\346\226\271\346\240\271.md" "b/Solutions/0069. x \347\232\204\345\271\263\346\226\271\346\240\271.md"
index ed2f22e6..d4d58368 100644
--- "a/Solutions/0069. x \347\232\204\345\271\263\346\226\271\346\240\271.md"
+++ "b/Solutions/0069. x \347\232\204\345\271\263\346\226\271\346\240\271.md"
@@ -15,14 +15,14 @@
- 示例 1:
-```Python
+```python
输入:x = 4
输出:2
```
- 示例 2:
-```Python
+```python
输入:x = 8
输出:2
解释:8 的算术平方根是 2.82842..., 由于返回类型是整数,小数部分将被舍去。
@@ -38,7 +38,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def mySqrt(self, x: int) -> int:
left = 0
diff --git "a/Solutions/0070. \347\210\254\346\245\274\346\242\257.md" "b/Solutions/0070. \347\210\254\346\245\274\346\242\257.md"
index 0d9f09ca..ee6a715c 100644
--- "a/Solutions/0070. \347\210\254\346\245\274\346\242\257.md"
+++ "b/Solutions/0070. \347\210\254\346\245\274\346\242\257.md"
@@ -17,7 +17,7 @@
- 示例 1:
-```Python
+```python
输入:n = 2
输出:2
解释:有两种方法可以爬到楼顶。
@@ -27,7 +27,7 @@
- 示例 2:
-```Python
+```python
输入:n = 3
输出:3
解释:有三种方法可以爬到楼顶。
@@ -53,7 +53,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def climbStairs(self, n: int) -> int:
if n == 1:
@@ -94,7 +94,7 @@ class Solution:
### 思路 2:代码
-```Python
+```python
class Solution:
def climbStairs(self, n: int) -> int:
dp = [0 for _ in range(n + 1)]
diff --git "a/Solutions/0072. \347\274\226\350\276\221\350\267\235\347\246\273.md" "b/Solutions/0072. \347\274\226\350\276\221\350\267\235\347\246\273.md"
index e9bd48c3..47c01de5 100644
--- "a/Solutions/0072. \347\274\226\350\276\221\350\267\235\347\246\273.md"
+++ "b/Solutions/0072. \347\274\226\350\276\221\350\267\235\347\246\273.md"
@@ -24,7 +24,7 @@
- 示例 1:
-```Python
+```python
输入:word1 = "horse", word2 = "ros"
输出:3
解释:
@@ -35,7 +35,7 @@ rose -> ros (删除 'e')
- 示例 2:
-```Python
+```python
输入:word1 = "intention", word2 = "execution"
输出:5
解释:
@@ -81,7 +81,7 @@ $dp[i][j] = \begin{cases} dp[i - 1][j - 1] & word1[i - 1] = word2[j - 1] \cr min
### 思路 1:代码
-```Python
+```python
class Solution:
def minDistance(self, word1: str, word2: str) -> int:
size1 = len(word1)
diff --git "a/Solutions/0073. \347\237\251\351\230\265\347\275\256\351\233\266.md" "b/Solutions/0073. \347\237\251\351\230\265\347\275\256\351\233\266.md"
index eba13b68..998dfb93 100644
--- "a/Solutions/0073. \347\237\251\351\230\265\347\275\256\351\233\266.md"
+++ "b/Solutions/0073. \347\237\251\351\230\265\347\275\256\351\233\266.md"
@@ -27,7 +27,7 @@
## 代码
-```Python
+```python
class Solution:
def setZeroes(self, matrix: List[List[int]]) -> None:
m = len(matrix)
diff --git "a/Solutions/0074. \346\220\234\347\264\242\344\272\214\347\273\264\347\237\251\351\230\265.md" "b/Solutions/0074. \346\220\234\347\264\242\344\272\214\347\273\264\347\237\251\351\230\265.md"
index b28bca94..0e47831b 100644
--- "a/Solutions/0074. \346\220\234\347\264\242\344\272\214\347\273\264\347\237\251\351\230\265.md"
+++ "b/Solutions/0074. \346\220\234\347\264\242\344\272\214\347\273\264\347\237\251\351\230\265.md"
@@ -20,7 +20,7 @@
- 示例 1:
-```Python
+```python
输入:matrix = [[1,3,5,7],[10,11,16,20],[23,30,34,60]], target = 3
输出:True
```
@@ -39,7 +39,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
# 二分查找对角线元素
def diagonalBinarySearch(self, matrix, diagonal, target):
diff --git "a/Solutions/0075. \351\242\234\350\211\262\345\210\206\347\261\273.md" "b/Solutions/0075. \351\242\234\350\211\262\345\210\206\347\261\273.md"
index 5464e375..87c162d8 100644
--- "a/Solutions/0075. \351\242\234\350\211\262\345\210\206\347\261\273.md"
+++ "b/Solutions/0075. \351\242\234\350\211\262\345\210\206\347\261\273.md"
@@ -20,14 +20,14 @@
- 示例 1:
-```Python
+```python
输入:nums = [2,0,2,1,1,0]
输出:[0,0,1,1,2,2]
```
- 示例 2:
-```Python
+```python
输入:nums = [2,0,1]
输出:[0,1,2]
```
@@ -48,7 +48,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def sortColors(self, nums: List[int]) -> None:
left = 0
diff --git "a/Solutions/0076. \346\234\200\345\260\217\350\246\206\347\233\226\345\255\220\344\270\262.md" "b/Solutions/0076. \346\234\200\345\260\217\350\246\206\347\233\226\345\255\220\344\270\262.md"
index 776b89d1..b82b56a8 100644
--- "a/Solutions/0076. \346\234\200\345\260\217\350\246\206\347\233\226\345\255\220\344\270\262.md"
+++ "b/Solutions/0076. \346\234\200\345\260\217\350\246\206\347\233\226\345\255\220\344\270\262.md"
@@ -18,14 +18,14 @@
- 示例 1:
-```Python
+```python
输入:s = "ADOBECODEBANC", t = "ABC"
输出:"BANC"
```
- 示例 2:
-```Python
+```python
输入:s = "a", t = "a"
输出:"a"
```
@@ -40,7 +40,7 @@
### 思路 1:代码
-```Python
+```python
import collections
class Solution:
diff --git "a/Solutions/0077. \347\273\204\345\220\210.md" "b/Solutions/0077. \347\273\204\345\220\210.md"
index 90d24eec..46bcebe5 100644
--- "a/Solutions/0077. \347\273\204\345\220\210.md"
+++ "b/Solutions/0077. \347\273\204\345\220\210.md"
@@ -22,7 +22,7 @@
## 代码
-```Python
+```python
class Solution:
res = []
path = []
diff --git "a/Solutions/0078. \345\255\220\351\233\206.md" "b/Solutions/0078. \345\255\220\351\233\206.md"
index 34b21a6b..5e97bd38 100644
--- "a/Solutions/0078. \345\255\220\351\233\206.md"
+++ "b/Solutions/0078. \345\255\220\351\233\206.md"
@@ -19,14 +19,14 @@
- 示例 1:
-```Python
+```python
输入 nums = [1,2,3]
输出 [[],[1],[2],[1,2],[3],[1,3],[2,3],[1,2,3]]
```
- 示例 2:
-```Python
+```python
输入:nums = [0]
输出:[[],[0]]
```
@@ -60,7 +60,7 @@
- 选择元素:将其添加到当前子集数组 `path` 中。
- 递归搜索:在选择该元素的情况下,继续递归考虑下一个位置上的元素。
- 撤销选择:将该元素从当前子集数组 `path` 中移除。
- ```Python
+ ```python
for i in range(index, len(nums)): # 枚举可选元素列表
path.append(nums[i]) # 选择元素
backtracking(nums, i + 1) # 递归搜索
@@ -73,7 +73,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def subsets(self, nums: List[int]) -> List[List[int]]:
res = [] # 存放所有符合条件结果的集合
@@ -134,7 +134,7 @@ class Solution:
### 思路 2:代码
-```Python
+```python
class Solution:
def subsets(self, nums: List[int]) -> List[List[int]]:
n = len(nums) # n 为集合 nums 的元素个数
diff --git "a/Solutions/0079. \345\215\225\350\257\215\346\220\234\347\264\242.md" "b/Solutions/0079. \345\215\225\350\257\215\346\220\234\347\264\242.md"
index c06b0ab5..d8149565 100644
--- "a/Solutions/0079. \345\215\225\350\257\215\346\220\234\347\264\242.md"
+++ "b/Solutions/0079. \345\215\225\350\257\215\346\220\234\347\264\242.md"
@@ -24,7 +24,7 @@

-```Python
+```python
输入:board = [["A","B","C","E"],["S","F","C","S"],["A","D","E","E"]], word = "ABCCED"
输出:true
```
@@ -33,7 +33,7 @@

-```Python
+```python
输入:board = [["A","B","C","E"],["S","F","C","S"],["A","D","E","E"]], word = "SEE"
输出:true
```
@@ -54,7 +54,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def exist(self, board: List[List[str]], word: str) -> bool:
directs = [(0, 1), (0, -1), (1, 0), (-1, 0)]
diff --git "a/Solutions/0080. \345\210\240\351\231\244\346\234\211\345\272\217\346\225\260\347\273\204\344\270\255\347\232\204\351\207\215\345\244\215\351\241\271 II.md" "b/Solutions/0080. \345\210\240\351\231\244\346\234\211\345\272\217\346\225\260\347\273\204\344\270\255\347\232\204\351\207\215\345\244\215\351\241\271 II.md"
index a45998af..749be212 100644
--- "a/Solutions/0080. \345\210\240\351\231\244\346\234\211\345\272\217\346\225\260\347\273\204\344\270\255\347\232\204\351\207\215\345\244\215\351\241\271 II.md"
+++ "b/Solutions/0080. \345\210\240\351\231\244\346\234\211\345\272\217\346\225\260\347\273\204\344\270\255\347\232\204\351\207\215\345\244\215\351\241\271 II.md"
@@ -19,7 +19,7 @@
- 示例 1:
-```Python
+```python
输入:nums = [1,1,1,2,2,3]
输出:5, nums = [1,1,2,2,3]
解释:函数应返回新长度 length = 5, 并且原数组的前五个元素被修改为 1, 1, 2, 2, 3 。 不需要考虑数组中超出新长度后面的元素。
@@ -27,7 +27,7 @@
- 示例 2:
-```Python
+```python
输入:nums = [0,0,1,1,1,1,2,3,3]
输出:7, nums = [0,0,1,1,2,3,3]
解释:函数应返回新长度 length = 7, 并且原数组的前五个元素被修改为 0, 0, 1, 1, 2, 3, 3 。 不需要考虑数组中超出新长度后面的元素。
@@ -48,7 +48,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def removeDuplicates(self, nums: List[int]) -> int:
size = len(nums)
diff --git "a/Solutions/0081. \346\220\234\347\264\242\346\227\213\350\275\254\346\216\222\345\272\217\346\225\260\347\273\204 II.md" "b/Solutions/0081. \346\220\234\347\264\242\346\227\213\350\275\254\346\216\222\345\272\217\346\225\260\347\273\204 II.md"
index dc0c6d18..2146c379 100644
--- "a/Solutions/0081. \346\220\234\347\264\242\346\227\213\350\275\254\346\216\222\345\272\217\346\225\260\347\273\204 II.md"
+++ "b/Solutions/0081. \346\220\234\347\264\242\346\227\213\350\275\254\346\216\222\345\272\217\346\225\260\347\273\204 II.md"
@@ -54,7 +54,7 @@
## 代码
-```Python
+```python
class Solution:
def search(self, nums: List[int], target: int) -> bool:
n = len(nums)
diff --git "a/Solutions/0082. \345\210\240\351\231\244\346\216\222\345\272\217\351\223\276\350\241\250\344\270\255\347\232\204\351\207\215\345\244\215\345\205\203\347\264\240 II.md" "b/Solutions/0082. \345\210\240\351\231\244\346\216\222\345\272\217\351\223\276\350\241\250\344\270\255\347\232\204\351\207\215\345\244\215\345\205\203\347\264\240 II.md"
index 899abcd9..031abdc0 100644
--- "a/Solutions/0082. \345\210\240\351\231\244\346\216\222\345\272\217\351\223\276\350\241\250\344\270\255\347\232\204\351\207\215\345\244\215\345\205\203\347\264\240 II.md"
+++ "b/Solutions/0082. \345\210\240\351\231\244\346\216\222\345\272\217\351\223\276\350\241\250\344\270\255\347\232\204\351\207\215\345\244\215\345\205\203\347\264\240 II.md"
@@ -19,7 +19,7 @@
- 示例 1:
-```Python
+```python
输入:head = [1,2,3,3,4,4,5]
输出:[1,2,5]
```
@@ -39,7 +39,7 @@
### 思路 1:代码
-```Python
+```python
# Definition for singly-linked list.
# class ListNode:
# def __init__(self, val=0, next=None):
diff --git "a/Solutions/0083. \345\210\240\351\231\244\346\216\222\345\272\217\351\223\276\350\241\250\344\270\255\347\232\204\351\207\215\345\244\215\345\205\203\347\264\240.md" "b/Solutions/0083. \345\210\240\351\231\244\346\216\222\345\272\217\351\223\276\350\241\250\344\270\255\347\232\204\351\207\215\345\244\215\345\205\203\347\264\240.md"
index 7b4219e0..65e7cbad 100644
--- "a/Solutions/0083. \345\210\240\351\231\244\346\216\222\345\272\217\351\223\276\350\241\250\344\270\255\347\232\204\351\207\215\345\244\215\345\205\203\347\264\240.md"
+++ "b/Solutions/0083. \345\210\240\351\231\244\346\216\222\345\272\217\351\223\276\350\241\250\344\270\255\347\232\204\351\207\215\345\244\215\345\205\203\347\264\240.md"
@@ -19,7 +19,7 @@
- 示例 1:
-```Python
+```python
输入:head = [1,1,2,3,3]
输出:[1,2,3]
```
@@ -36,7 +36,7 @@
### 思路 1:遍历代码
-```Python
+```python
class Solution:
def deleteDuplicates(self, head: ListNode) -> ListNode:
if head == None:
diff --git "a/Solutions/0084. \346\237\261\347\212\266\345\233\276\344\270\255\346\234\200\345\244\247\347\232\204\347\237\251\345\275\242.md" "b/Solutions/0084. \346\237\261\347\212\266\345\233\276\344\270\255\346\234\200\345\244\247\347\232\204\347\237\251\345\275\242.md"
index 061d47a3..dc771d44 100644
--- "a/Solutions/0084. \346\237\261\347\212\266\345\233\276\344\270\255\346\234\200\345\244\247\347\232\204\347\237\251\345\275\242.md"
+++ "b/Solutions/0084. \346\237\261\347\212\266\345\233\276\344\270\255\346\234\200\345\244\247\347\232\204\347\237\251\345\275\242.md"
@@ -26,7 +26,7 @@
## 代码
-```Python
+```python
class Solution:
def largestRectangleArea(self, heights: List[int]) -> int:
heights.append(0)
diff --git "a/Solutions/0088. \345\220\210\345\271\266\344\270\244\344\270\252\346\234\211\345\272\217\346\225\260\347\273\204.md" "b/Solutions/0088. \345\220\210\345\271\266\344\270\244\344\270\252\346\234\211\345\272\217\346\225\260\347\273\204.md"
index 19db57cf..31807d4d 100644
--- "a/Solutions/0088. \345\220\210\345\271\266\344\270\244\344\270\252\346\234\211\345\272\217\346\225\260\347\273\204.md"
+++ "b/Solutions/0088. \345\220\210\345\271\266\344\270\244\344\270\252\346\234\211\345\272\217\346\225\260\347\273\204.md"
@@ -22,7 +22,7 @@
- 示例 1:
-```Python
+```python
输入:nums1 = [1,2,3,0,0,0], m = 3, nums2 = [2,5,6], n = 3
输出:[1,2,2,3,5,6]
解释:需要合并 [1,2,3] 和 [2,5,6] 。
@@ -31,7 +31,7 @@
- 示例 2:
-```Python
+```python
输入:nums1 = [1], m = 1, nums2 = [], n = 0
输出:[1]
解释:需要合并 [1] 和 [] 。
@@ -48,7 +48,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def merge(self, nums1: List[int], m: int, nums2: List[int], n: int) -> None:
index1 = m - 1
diff --git "a/Solutions/0089. \346\240\274\351\233\267\347\274\226\347\240\201.md" "b/Solutions/0089. \346\240\274\351\233\267\347\274\226\347\240\201.md"
index 44b324cd..e529af9e 100644
--- "a/Solutions/0089. \346\240\274\351\233\267\347\274\226\347\240\201.md"
+++ "b/Solutions/0089. \346\240\274\351\233\267\347\274\226\347\240\201.md"
@@ -19,7 +19,7 @@
## 代码
-```Python
+```python
class Solution:
def grayCode(self, n: int) -> List[int]:
gray = []
diff --git "a/Solutions/0090. \345\255\220\351\233\206 II.md" "b/Solutions/0090. \345\255\220\351\233\206 II.md"
index efc75d5e..5bbbabed 100644
--- "a/Solutions/0090. \345\255\220\351\233\206 II.md"
+++ "b/Solutions/0090. \345\255\220\351\233\206 II.md"
@@ -19,7 +19,7 @@
- 示例 1:
-```Python
+```python
输入:nums = [1,2,2]
输出:[[],[1],[1,2],[1,2,2],[2],[2,2]]
```
@@ -47,7 +47,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def backtrack(self, nums, index, res, path):
res.append(path[:])
@@ -110,7 +110,7 @@ class Solution:
### 思路 2:代码
-```Python
+```python
class Solution:
def subsetsWithDup(self, nums: List[int]) -> List[List[int]]:
nums.sort()
diff --git "a/Solutions/0091. \350\247\243\347\240\201\346\226\271\346\263\225.md" "b/Solutions/0091. \350\247\243\347\240\201\346\226\271\346\263\225.md"
index 164b1523..18045cf5 100644
--- "a/Solutions/0091. \350\247\243\347\240\201\346\226\271\346\263\225.md"
+++ "b/Solutions/0091. \350\247\243\347\240\201\346\226\271\346\263\225.md"
@@ -29,7 +29,7 @@
- 示例 1:
-```Python
+```python
输入:s = "226"
输出:3
解释:它可以解码为 "BZ" (2 26), "VF" (22 6), 或者 "BBF" (2 2 6) 。
@@ -72,7 +72,7 @@ $dp[i] += \begin{cases} \begin{array} \ dp[i-1] & s[i] \ne 0 \cr dp[i-2] & s[i-
### 思路 1:动态规划代码
-```Python
+```python
class Solution:
def numDecodings(self, s: str) -> int:
size = len(s)
diff --git "a/Solutions/0092. \345\217\215\350\275\254\351\223\276\350\241\250 II.md" "b/Solutions/0092. \345\217\215\350\275\254\351\223\276\350\241\250 II.md"
index 2081128e..df8b71a0 100644
--- "a/Solutions/0092. \345\217\215\350\275\254\351\223\276\350\241\250 II.md"
+++ "b/Solutions/0092. \345\217\215\350\275\254\351\223\276\350\241\250 II.md"
@@ -20,7 +20,7 @@
- 示例 1:
-```Python
+```python
输入:head = [1,2,3,4,5], left = 2, right = 4
输出:[1,4,3,2,5]
```
@@ -52,7 +52,7 @@
### 思路 1:代码
-```Python
+```python
# Definition for singly-linked list.
# class ListNode:
# def __init__(self, val=0, next=None):
@@ -114,7 +114,7 @@ class Solution:
### 思路 2:代码
-```Python
+```python
class Solution:
def reverseBetween(self, head: Optional[ListNode], left: int, right: int) -> Optional[ListNode]:
if left == 1:
diff --git "a/Solutions/0093. \345\244\215\345\216\237 IP \345\234\260\345\235\200.md" "b/Solutions/0093. \345\244\215\345\216\237 IP \345\234\260\345\235\200.md"
index d2dcb417..c085a047 100644
--- "a/Solutions/0093. \345\244\215\345\216\237 IP \345\234\260\345\235\200.md"
+++ "b/Solutions/0093. \345\244\215\345\216\237 IP \345\234\260\345\235\200.md"
@@ -19,14 +19,14 @@
- 示例 1:
-```Python
+```python
输入:s = "25525511135"
输出:["255.255.11.135","255.255.111.35"]
```
- 示例 2:
-```Python
+```python
输入:s = "0000"
输出:["0.0.0.0"]
```
@@ -58,7 +58,7 @@
- 递归搜索:在选择该子段值的情况下,继续递归从剩下字符中,选择下一个子段值。
- 撤销选择:将该子段值从当前结果数组 `path` 中移除。
- ```Python
+ ```python
for i in range(index, len(s)): # 枚举可选元素列表
sub = s[index: i + 1]
# 如果当前值不在 0 ~ 255 之间,直接跳过
@@ -82,7 +82,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def restoreIpAddresses(self, s: str) -> List[str]:
res = []
diff --git "a/Solutions/0094. \344\272\214\345\217\211\346\240\221\347\232\204\344\270\255\345\272\217\351\201\215\345\216\206.md" "b/Solutions/0094. \344\272\214\345\217\211\346\240\221\347\232\204\344\270\255\345\272\217\351\201\215\345\216\206.md"
index 70ae77da..e16ae1cc 100644
--- "a/Solutions/0094. \344\272\214\345\217\211\346\240\221\347\232\204\344\270\255\345\272\217\351\201\215\345\216\206.md"
+++ "b/Solutions/0094. \344\272\214\345\217\211\346\240\221\347\232\204\344\270\255\345\272\217\351\201\215\345\216\206.md"
@@ -20,14 +20,14 @@

-```Python
+```python
输入:root = [1,null,2,3]
输出:[1,3,2]
```
- 示例 2:
-```Python
+```python
输入:root = []
输出:[]
```
@@ -45,7 +45,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def inorderTraversal(self, root: TreeNode) -> List[int]:
res = []
@@ -82,7 +82,7 @@ class Solution:
### 思路 2:代码
-```Python
+```python
class Solution:
def inorderTraversal(self, root: Optional[TreeNode]) -> List[int]:
if not root: # 二叉树为空直接返回
diff --git "a/Solutions/0095. \344\270\215\345\220\214\347\232\204\344\272\214\345\217\211\346\220\234\347\264\242\346\240\221 II.md" "b/Solutions/0095. \344\270\215\345\220\214\347\232\204\344\272\214\345\217\211\346\220\234\347\264\242\346\240\221 II.md"
index 56adf99f..eb13d9d2 100644
--- "a/Solutions/0095. \344\270\215\345\220\214\347\232\204\344\272\214\345\217\211\346\220\234\347\264\242\346\240\221 II.md"
+++ "b/Solutions/0095. \344\270\215\345\220\214\347\232\204\344\272\214\345\217\211\346\220\234\347\264\242\346\240\221 II.md"
@@ -22,7 +22,7 @@
## 代码
-```Python
+```python
class Solution:
def generateTrees(self, n: int) -> List[TreeNode]:
if n == 0:
diff --git "a/Solutions/0096. \344\270\215\345\220\214\347\232\204\344\272\214\345\217\211\346\220\234\347\264\242\346\240\221.md" "b/Solutions/0096. \344\270\215\345\220\214\347\232\204\344\272\214\345\217\211\346\220\234\347\264\242\346\240\221.md"
index 89e33ab0..f063b8bc 100644
--- "a/Solutions/0096. \344\270\215\345\220\214\347\232\204\344\272\214\345\217\211\346\220\234\347\264\242\346\240\221.md"
+++ "b/Solutions/0096. \344\270\215\345\220\214\347\232\204\344\272\214\345\217\211\346\220\234\347\264\242\346\240\221.md"
@@ -19,14 +19,14 @@

-```Python
+```python
输入:n = 3
输出:5
```
- 示例 2:
-```Python
+```python
输入:n = 1
输出:1
```
@@ -81,7 +81,7 @@ $dp[i] = \sum_{1 \le j \le i} \lbrace dp[j - 1] \times dp[i - j] \rbrace$
### 思路 1:代码
-```Python
+```python
class Solution:
def numTrees(self, n: int) -> int:
dp = [0 for _ in range(n + 1)]
diff --git "a/Solutions/0098. \351\252\214\350\257\201\344\272\214\345\217\211\346\220\234\347\264\242\346\240\221.md" "b/Solutions/0098. \351\252\214\350\257\201\344\272\214\345\217\211\346\220\234\347\264\242\346\240\221.md"
index 3855f4c5..3a6a6a7c 100644
--- "a/Solutions/0098. \351\252\214\350\257\201\344\272\214\345\217\211\346\220\234\347\264\242\346\240\221.md"
+++ "b/Solutions/0098. \351\252\214\350\257\201\344\272\214\345\217\211\346\220\234\347\264\242\346\240\221.md"
@@ -24,7 +24,7 @@

-```Python
+```python
输入:root = [2,1,3]
输出:true
```
@@ -33,7 +33,7 @@

-```Python
+```python
输入:root = [5,1,4,null,null,3,6]
输出:false
解释:根节点的值是 5 ,但是右子节点的值是 4 。
@@ -54,7 +54,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def isValidBST(self, root: TreeNode) -> bool:
def preorderTraversal(root, min_v, max_v):
diff --git "a/Solutions/0100. \347\233\270\345\220\214\347\232\204\346\240\221.md" "b/Solutions/0100. \347\233\270\345\220\214\347\232\204\346\240\221.md"
index 30efc04f..6c783c32 100644
--- "a/Solutions/0100. \347\233\270\345\220\214\347\232\204\346\240\221.md"
+++ "b/Solutions/0100. \347\233\270\345\220\214\347\232\204\346\240\221.md"
@@ -18,7 +18,7 @@
## 代码
-```Python
+```python
class Solution:
def isSameTree(self, p: TreeNode, q: TreeNode) -> bool:
if not p and not q:
diff --git "a/Solutions/0101. \345\257\271\347\247\260\344\272\214\345\217\211\346\240\221.md" "b/Solutions/0101. \345\257\271\347\247\260\344\272\214\345\217\211\346\240\221.md"
index d25c6d57..306de530 100644
--- "a/Solutions/0101. \345\257\271\347\247\260\344\272\214\345\217\211\346\240\221.md"
+++ "b/Solutions/0101. \345\257\271\347\247\260\344\272\214\345\217\211\346\240\221.md"
@@ -20,7 +20,7 @@

-```Python
+```python
输入:root = [1,2,2,3,4,4,3]
输出:true
```
@@ -29,7 +29,7 @@

-```Python
+```python
输入:root = [1,2,2,null,3,null,3]
输出:false
```
@@ -57,7 +57,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def isSymmetric(self, root: TreeNode) -> bool:
if root == None:
diff --git "a/Solutions/0102. \344\272\214\345\217\211\346\240\221\347\232\204\345\261\202\345\272\217\351\201\215\345\216\206.md" "b/Solutions/0102. \344\272\214\345\217\211\346\240\221\347\232\204\345\261\202\345\272\217\351\201\215\345\216\206.md"
index c0e4f7d4..1c00080d 100644
--- "a/Solutions/0102. \344\272\214\345\217\211\346\240\221\347\232\204\345\261\202\345\272\217\351\201\215\345\216\206.md"
+++ "b/Solutions/0102. \344\272\214\345\217\211\346\240\221\347\232\204\345\261\202\345\272\217\351\201\215\345\216\206.md"
@@ -19,14 +19,14 @@

-```Python
+```python
输入:root = [3,9,20,null,null,15,7]
输出:[[3],[9,20],[15,7]]
```
- 示例 2:
-```Python
+```python
输入:root = [1]
输出:[[1]
```
@@ -47,7 +47,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def levelOrder(self, root: TreeNode) -> List[List[int]]:
if not root:
diff --git "a/Solutions/0103. \344\272\214\345\217\211\346\240\221\347\232\204\351\224\257\351\275\277\345\275\242\345\261\202\345\272\217\351\201\215\345\216\206.md" "b/Solutions/0103. \344\272\214\345\217\211\346\240\221\347\232\204\351\224\257\351\275\277\345\275\242\345\261\202\345\272\217\351\201\215\345\216\206.md"
index 460d47a8..b2f79dc1 100644
--- "a/Solutions/0103. \344\272\214\345\217\211\346\240\221\347\232\204\351\224\257\351\275\277\345\275\242\345\261\202\345\272\217\351\201\215\345\216\206.md"
+++ "b/Solutions/0103. \344\272\214\345\217\211\346\240\221\347\232\204\351\224\257\351\275\277\345\275\242\345\261\202\345\272\217\351\201\215\345\216\206.md"
@@ -19,14 +19,14 @@

-```Python
+```python
输入:root = [3,9,20,null,null,15,7]
输出:[[3],[20,9],[15,7]]
```
- 示例 2:
-```Python
+```python
输入:root = [1]
输出:[[1]]
```
@@ -57,7 +57,7 @@
### 思路 1:代码
-```Python
+```python
import collections
class Solution:
def zigzagLevelOrder(self, root: TreeNode) -> List[List[int]]:
diff --git "a/Solutions/0104. \344\272\214\345\217\211\346\240\221\347\232\204\346\234\200\345\244\247\346\267\261\345\272\246.md" "b/Solutions/0104. \344\272\214\345\217\211\346\240\221\347\232\204\346\234\200\345\244\247\346\267\261\345\272\246.md"
index 6b9b0d3e..11d67699 100644
--- "a/Solutions/0104. \344\272\214\345\217\211\346\240\221\347\232\204\346\234\200\345\244\247\346\267\261\345\272\246.md"
+++ "b/Solutions/0104. \344\272\214\345\217\211\346\240\221\347\232\204\346\234\200\345\244\247\346\267\261\345\272\246.md"
@@ -18,7 +18,7 @@
- 示例 1:
-```Python
+```python
输入:[3,9,20,null,null,15,7]
对应二叉树
3
@@ -46,7 +46,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def maxDepth(self, root: Optional[TreeNode]) -> int:
if not root:
diff --git "a/Solutions/0105. \344\273\216\345\211\215\345\272\217\344\270\216\344\270\255\345\272\217\351\201\215\345\216\206\345\272\217\345\210\227\346\236\204\351\200\240\344\272\214\345\217\211\346\240\221.md" "b/Solutions/0105. \344\273\216\345\211\215\345\272\217\344\270\216\344\270\255\345\272\217\351\201\215\345\216\206\345\272\217\345\210\227\346\236\204\351\200\240\344\272\214\345\217\211\346\240\221.md"
index 6ecd0c81..cebb9c28 100644
--- "a/Solutions/0105. \344\273\216\345\211\215\345\272\217\344\270\216\344\270\255\345\272\217\351\201\215\345\216\206\345\272\217\345\210\227\346\236\204\351\200\240\344\272\214\345\217\211\346\240\221.md"
+++ "b/Solutions/0105. \344\273\216\345\211\215\345\272\217\344\270\216\344\270\255\345\272\217\351\201\215\345\216\206\345\272\217\345\210\227\346\236\204\351\200\240\344\272\214\345\217\211\346\240\221.md"
@@ -25,14 +25,14 @@

-```Python
+```python
输入: preorder = [3,9,20,15,7], inorder = [9,3,15,20,7]
输出: [3,9,20,null,null,15,7]
```
- 示例 2:
-```Python
+```python
输入: preorder = [-1], inorder = [-1]
输出: [-1]
```
@@ -50,7 +50,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def buildTree(self, preorder: List[int], inorder: List[int]) -> TreeNode:
def createTree(preorder, inorder, n):
diff --git "a/Solutions/0106. \344\273\216\344\270\255\345\272\217\344\270\216\345\220\216\345\272\217\351\201\215\345\216\206\345\272\217\345\210\227\346\236\204\351\200\240\344\272\214\345\217\211\346\240\221.md" "b/Solutions/0106. \344\273\216\344\270\255\345\272\217\344\270\216\345\220\216\345\272\217\351\201\215\345\216\206\345\272\217\345\210\227\346\236\204\351\200\240\344\272\214\345\217\211\346\240\221.md"
index 601bee83..b1f69122 100644
--- "a/Solutions/0106. \344\273\216\344\270\255\345\272\217\344\270\216\345\220\216\345\272\217\351\201\215\345\216\206\345\272\217\345\210\227\346\236\204\351\200\240\344\272\214\345\217\211\346\240\221.md"
+++ "b/Solutions/0106. \344\273\216\344\270\255\345\272\217\344\270\216\345\220\216\345\272\217\351\201\215\345\216\206\345\272\217\345\210\227\346\236\204\351\200\240\344\272\214\345\217\211\346\240\221.md"
@@ -26,14 +26,14 @@

-```Python
+```python
输入:inorder = [9,3,15,20,7], postorder = [9,15,7,20,3]
输出:[3,9,20,null,null,15,7]
```
- 示例 2:
-```Python
+```python
输入:inorder = [-1], postorder = [-1]
输出:[-1]
```
@@ -51,7 +51,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def buildTree(self, inorder: List[int], postorder: List[int]) -> TreeNode:
def createTree(inorder, postorder, n):
diff --git "a/Solutions/0107. \344\272\214\345\217\211\346\240\221\347\232\204\345\261\202\345\272\217\351\201\215\345\216\206 II.md" "b/Solutions/0107. \344\272\214\345\217\211\346\240\221\347\232\204\345\261\202\345\272\217\351\201\215\345\216\206 II.md"
index e26a65db..6a0e7af9 100644
--- "a/Solutions/0107. \344\272\214\345\217\211\346\240\221\347\232\204\345\261\202\345\272\217\351\201\215\345\216\206 II.md"
+++ "b/Solutions/0107. \344\272\214\345\217\211\346\240\221\347\232\204\345\261\202\345\272\217\351\201\215\345\216\206 II.md"
@@ -22,7 +22,7 @@
## 代码
-```Python
+```python
class Solution:
def levelOrderBottom(self, root: TreeNode) -> List[List[int]]:
if not root:
diff --git "a/Solutions/0108. \345\260\206\346\234\211\345\272\217\346\225\260\347\273\204\350\275\254\346\215\242\344\270\272\344\272\214\345\217\211\346\220\234\347\264\242\346\240\221.md" "b/Solutions/0108. \345\260\206\346\234\211\345\272\217\346\225\260\347\273\204\350\275\254\346\215\242\344\270\272\344\272\214\345\217\211\346\220\234\347\264\242\346\240\221.md"
index c5786e28..9445bfda 100644
--- "a/Solutions/0108. \345\260\206\346\234\211\345\272\217\346\225\260\347\273\204\350\275\254\346\215\242\344\270\272\344\272\214\345\217\211\346\220\234\347\264\242\346\240\221.md"
+++ "b/Solutions/0108. \345\260\206\346\234\211\345\272\217\346\225\260\347\273\204\350\275\254\346\215\242\344\270\272\344\272\214\345\217\211\346\220\234\347\264\242\346\240\221.md"
@@ -21,7 +21,7 @@

-```Python
+```python
输入:nums = [-10,-3,0,5,9]
输出:[0,-3,9,-10,null,5]
解释:[0,-10,5,null,-3,null,9] 也将被视为正确答案
@@ -31,7 +31,7 @@

-```Python
+```python
输入:nums = [1,3]
输出:[3,1]
解释:[1,null,3] 和 [3,1] 都是高度平衡二叉搜索树。
@@ -47,7 +47,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def sortedArrayToBST(self, nums: List[int]) -> Optional[TreeNode]:
def build(left, right):
diff --git "a/Solutions/0110. \345\271\263\350\241\241\344\272\214\345\217\211\346\240\221.md" "b/Solutions/0110. \345\271\263\350\241\241\344\272\214\345\217\211\346\240\221.md"
index 68442953..d71d3306 100644
--- "a/Solutions/0110. \345\271\263\350\241\241\344\272\214\345\217\211\346\240\221.md"
+++ "b/Solutions/0110. \345\271\263\350\241\241\344\272\214\345\217\211\346\240\221.md"
@@ -21,7 +21,7 @@

-```Python
+```python
输入:root = [3,9,20,null,null,15,7]
输出:True
```
@@ -30,7 +30,7 @@

-```Python
+```python
输入:root = [1,2,2,3,3,null,null,4,4]
输出:False
```
@@ -45,7 +45,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def isBalanced(self, root: TreeNode) -> bool:
def height(root: TreeNode) -> int:
diff --git "a/Solutions/0111. \344\272\214\345\217\211\346\240\221\347\232\204\346\234\200\345\260\217\346\267\261\345\272\246.md" "b/Solutions/0111. \344\272\214\345\217\211\346\240\221\347\232\204\346\234\200\345\260\217\346\267\261\345\272\246.md"
index dbc0ab5f..1f31ee91 100644
--- "a/Solutions/0111. \344\272\214\345\217\211\346\240\221\347\232\204\346\234\200\345\260\217\346\267\261\345\272\246.md"
+++ "b/Solutions/0111. \344\272\214\345\217\211\346\240\221\347\232\204\346\234\200\345\260\217\346\267\261\345\272\246.md"
@@ -17,7 +17,7 @@
## 代码
-```Python
+```python
class Solution:
def minDepth(self, root: TreeNode) -> int:
# 遍历到空节点,直接返回 0
diff --git "a/Solutions/0112. \350\267\257\345\276\204\346\200\273\345\222\214.md" "b/Solutions/0112. \350\267\257\345\276\204\346\200\273\345\222\214.md"
index a5b981ab..28d697fc 100644
--- "a/Solutions/0112. \350\267\257\345\276\204\346\200\273\345\222\214.md"
+++ "b/Solutions/0112. \350\267\257\345\276\204\346\200\273\345\222\214.md"
@@ -21,7 +21,7 @@

-```Python
+```python
输入:root = [5,4,8,11,null,13,4,7,2,null,null,null,1], targetSum = 22
输出:true
解释:等于目标和的根节点到叶节点路径如上图所示。
@@ -31,7 +31,7 @@

-```Python
+```python
输入:root = [1,2,3], targetSum = 5
输出:false
解释:树中存在两条根节点到叶子节点的路径:
@@ -53,7 +53,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def hasPathSum(self, root: TreeNode, targetSum: int) -> bool:
return self.sum(root, targetSum, 0)
diff --git "a/Solutions/0113. \350\267\257\345\276\204\346\200\273\345\222\214 II.md" "b/Solutions/0113. \350\267\257\345\276\204\346\200\273\345\222\214 II.md"
index b2c87f18..0d2b5704 100644
--- "a/Solutions/0113. \350\267\257\345\276\204\346\200\273\345\222\214 II.md"
+++ "b/Solutions/0113. \350\267\257\345\276\204\346\200\273\345\222\214 II.md"
@@ -22,7 +22,7 @@

-```Python
+```python
输入:root = [5,4,8,11,null,13,4,7,2,null,null,5,1], targetSum = 22
输出:[[5,4,11,2],[5,8,4,5]]
```
@@ -31,7 +31,7 @@

-```Python
+```python
输入:root = [1,2,3], targetSum = 5
输出:[]
```
@@ -55,7 +55,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def pathSum(self, root: TreeNode, targetSum: int) -> List[List[int]]:
res = []
diff --git "a/Solutions/0115. \344\270\215\345\220\214\347\232\204\345\255\220\345\272\217\345\210\227.md" "b/Solutions/0115. \344\270\215\345\220\214\347\232\204\345\255\220\345\272\217\345\210\227.md"
index c5b4a3eb..9d94a0a1 100644
--- "a/Solutions/0115. \344\270\215\345\220\214\347\232\204\345\255\220\345\272\217\345\210\227.md"
+++ "b/Solutions/0115. \344\270\215\345\220\214\347\232\204\345\255\220\345\272\217\345\210\227.md"
@@ -19,7 +19,7 @@
- 示例 1:
-```Python
+```python
输入:s = "rabbbit", t = "rabbit"
输出:3
解释:如下图所示, 有 3 种可以从 s 中得到 "rabbit" 的方案。
@@ -62,7 +62,7 @@ $\underline{rab}b\underline{bit}$
### 思路 1:动态规划代码
-```Python
+```python
class Solution:
def numDistinct(self, s: str, t: str) -> int:
size_s = len(s)
diff --git "a/Solutions/0116. \345\241\253\345\205\205\346\257\217\344\270\252\350\212\202\347\202\271\347\232\204\344\270\213\344\270\200\344\270\252\345\217\263\344\276\247\350\212\202\347\202\271\346\214\207\351\222\210.md" "b/Solutions/0116. \345\241\253\345\205\205\346\257\217\344\270\252\350\212\202\347\202\271\347\232\204\344\270\213\344\270\200\344\270\252\345\217\263\344\276\247\350\212\202\347\202\271\346\214\207\351\222\210.md"
index 7be593a9..d025c511 100644
--- "a/Solutions/0116. \345\241\253\345\205\205\346\257\217\344\270\252\350\212\202\347\202\271\347\232\204\344\270\213\344\270\200\344\270\252\345\217\263\344\276\247\350\212\202\347\202\271\346\214\207\351\222\210.md"
+++ "b/Solutions/0116. \345\241\253\345\205\205\346\257\217\344\270\252\350\212\202\347\202\271\347\232\204\344\270\213\344\270\200\344\270\252\345\217\263\344\276\247\350\212\202\347\202\271\346\214\207\351\222\210.md"
@@ -7,7 +7,7 @@
给定一个完美二叉树,所有叶子节点都在同一层,每个父节点都有两个子节点。二叉树结构如下:
-```Python
+```python
struct Node {
int val;
Node *left;
@@ -27,7 +27,7 @@ struct Node {
## 代码
-```Python
+```python
import collections
class Solution:
diff --git "a/Solutions/0117. \345\241\253\345\205\205\346\257\217\344\270\252\350\212\202\347\202\271\347\232\204\344\270\213\344\270\200\344\270\252\345\217\263\344\276\247\350\212\202\347\202\271\346\214\207\351\222\210 II.md" "b/Solutions/0117. \345\241\253\345\205\205\346\257\217\344\270\252\350\212\202\347\202\271\347\232\204\344\270\213\344\270\200\344\270\252\345\217\263\344\276\247\350\212\202\347\202\271\346\214\207\351\222\210 II.md"
index f78c7f0a..8adf567f 100644
--- "a/Solutions/0117. \345\241\253\345\205\205\346\257\217\344\270\252\350\212\202\347\202\271\347\232\204\344\270\213\344\270\200\344\270\252\345\217\263\344\276\247\350\212\202\347\202\271\346\214\207\351\222\210 II.md"
+++ "b/Solutions/0117. \345\241\253\345\205\205\346\257\217\344\270\252\350\212\202\347\202\271\347\232\204\344\270\213\344\270\200\344\270\252\345\217\263\344\276\247\350\212\202\347\202\271\346\214\207\351\222\210 II.md"
@@ -7,7 +7,7 @@
给定一个完美二叉树,二叉树结构如下:
-```Python
+```python
struct Node {
int val;
Node *left;
@@ -25,7 +25,7 @@ struct Node {
## 代码
-```Python
+```python
import collections
class Solution:
diff --git "a/Solutions/0118. \346\235\250\350\276\211\344\270\211\350\247\222.md" "b/Solutions/0118. \346\235\250\350\276\211\344\270\211\350\247\222.md"
index feac6b60..2060990c 100644
--- "a/Solutions/0118. \346\235\250\350\276\211\344\270\211\350\247\222.md"
+++ "b/Solutions/0118. \346\235\250\350\276\211\344\270\211\350\247\222.md"
@@ -17,7 +17,7 @@
- 示例 1:
-```Python
+```python
输入:numRows = 5
输出:[[1],[1,1],[1,2,1],[1,3,3,1],[1,4,6,4,1]]
即
@@ -57,7 +57,7 @@
### 思路 1:动态规划代码
-```Python
+```python
class Solution:
def generate(self, numRows: int) -> List[List[int]]:
dp = [[0] * i for i in range(1, numRows + 1)]
@@ -95,7 +95,7 @@ class Solution:
### 思路 2:动态规划 + 滚动数组优化代码
-```Python
+```python
class Solution:
def generate(self, numRows: int) -> List[List[int]]:
dp = [1 for _ in range(numRows + 1)]
diff --git "a/Solutions/0119. \346\235\250\350\276\211\344\270\211\350\247\222 II.md" "b/Solutions/0119. \346\235\250\350\276\211\344\270\211\350\247\222 II.md"
index 61620fb1..91b41a60 100644
--- "a/Solutions/0119. \346\235\250\350\276\211\344\270\211\350\247\222 II.md"
+++ "b/Solutions/0119. \346\235\250\350\276\211\344\270\211\350\247\222 II.md"
@@ -18,7 +18,7 @@
- 示例 1:
-```Python
+```python
输入:rowIndex = 3
输出:[1,3,3,1]
```
@@ -52,7 +52,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def getRow(self, rowIndex: int) -> List[int]:
# 本题从 0 行开始计算
@@ -91,7 +91,7 @@ class Solution:
### 思路 2:动态规划 + 滚动数组优化代码
-```Python
+```python
class Solution:
def getRow(self, rowIndex: int) -> List[int]:
# 本题从 0 行开始计算
diff --git "a/Solutions/0120. \344\270\211\350\247\222\345\275\242\346\234\200\345\260\217\350\267\257\345\276\204\345\222\214.md" "b/Solutions/0120. \344\270\211\350\247\222\345\275\242\346\234\200\345\260\217\350\267\257\345\276\204\345\222\214.md"
index 4f0ba6d5..22e28c5a 100644
--- "a/Solutions/0120. \344\270\211\350\247\222\345\275\242\346\234\200\345\260\217\350\267\257\345\276\204\345\222\214.md"
+++ "b/Solutions/0120. \344\270\211\350\247\222\345\275\242\346\234\200\345\260\217\350\267\257\345\276\204\345\222\214.md"
@@ -22,7 +22,7 @@
- 示例 1:
-```Python
+```python
输入:triangle = [[2],[3,4],[6,5,7],[4,1,8,3]]
输出:11
解释:如下面简图所示:
@@ -61,7 +61,7 @@
### 思路 1:动态规划代码
-```Python
+```python
class Solution:
def minimumTotal(self, triangle: List[List[int]]) -> int:
size = len(triangle)
diff --git "a/Solutions/0121. \344\271\260\345\215\226\350\202\241\347\245\250\347\232\204\346\234\200\344\275\263\346\227\266\346\234\272.md" "b/Solutions/0121. \344\271\260\345\215\226\350\202\241\347\245\250\347\232\204\346\234\200\344\275\263\346\227\266\346\234\272.md"
index 56a826a1..62f4eb89 100644
--- "a/Solutions/0121. \344\271\260\345\215\226\350\202\241\347\245\250\347\232\204\346\234\200\344\275\263\346\227\266\346\234\272.md"
+++ "b/Solutions/0121. \344\271\260\345\215\226\350\202\241\347\245\250\347\232\204\346\234\200\344\275\263\346\227\266\346\234\272.md"
@@ -18,7 +18,7 @@
- 示例 1:
-```Python
+```python
输入:[7,1,5,3,6,4]
输出:5
解释:在第 2 天(股票价格 = 1)的时候买入,在第 5 天(股票价格 = 6)的时候卖出,最大利润 = 6-1 = 5 。
@@ -27,7 +27,7 @@
- 示例 2:
-```Python
+```python
输入:prices = [7,6,4,3,1]
输出:0
解释:在这种情况下, 没有交易完成, 所以最大利润为 0。
@@ -48,7 +48,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def maxProfit(self, prices: List[int]) -> int:
minprice = 10010
diff --git "a/Solutions/0122. \344\271\260\345\215\226\350\202\241\347\245\250\347\232\204\346\234\200\344\275\263\346\227\266\346\234\272 II.md" "b/Solutions/0122. \344\271\260\345\215\226\350\202\241\347\245\250\347\232\204\346\234\200\344\275\263\346\227\266\346\234\272 II.md"
index 8ec04664..1e96384b 100644
--- "a/Solutions/0122. \344\271\260\345\215\226\350\202\241\347\245\250\347\232\204\346\234\200\344\275\263\346\227\266\346\234\272 II.md"
+++ "b/Solutions/0122. \344\271\260\345\215\226\350\202\241\347\245\250\347\232\204\346\234\200\344\275\263\346\227\266\346\234\272 II.md"
@@ -18,7 +18,7 @@
- 示例 1:
-```Python
+```python
输入:prices = [7,1,5,3,6,4]
输出:7
解释:在第 2 天(股票价格 = 1)的时候买入,在第 3 天(股票价格 = 5)的时候卖出, 这笔交易所能获得利润 = 5 - 1 = 4 。
@@ -28,7 +28,7 @@
- 示例 2:
-```Python
+```python
输入:prices = [1,2,3,4,5]
输出:4
解释:在第 1 天(股票价格 = 1)的时候买入,在第 5 天 (股票价格 = 5)的时候卖出, 这笔交易所能获得利润 = 5 - 1 = 4 。
@@ -49,7 +49,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def maxProfit(self, prices: List[int]) -> int:
ans = 0
diff --git "a/Solutions/0123. \344\271\260\345\215\226\350\202\241\347\245\250\347\232\204\346\234\200\344\275\263\346\227\266\346\234\272 III.md" "b/Solutions/0123. \344\271\260\345\215\226\350\202\241\347\245\250\347\232\204\346\234\200\344\275\263\346\227\266\346\234\272 III.md"
index d30ab615..570eb8b9 100644
--- "a/Solutions/0123. \344\271\260\345\215\226\350\202\241\347\245\250\347\232\204\346\234\200\344\275\263\346\227\266\346\234\272 III.md"
+++ "b/Solutions/0123. \344\271\260\345\215\226\350\202\241\347\245\250\347\232\204\346\234\200\344\275\263\346\227\266\346\234\272 III.md"
@@ -53,7 +53,7 @@
## 代码
-```Python
+```python
class Solution:
def maxProfit(self, prices: List[int]) -> int:
size = len(prices)
diff --git "a/Solutions/0124. \344\272\214\345\217\211\346\240\221\344\270\255\347\232\204\346\234\200\345\244\247\350\267\257\345\276\204\345\222\214.md" "b/Solutions/0124. \344\272\214\345\217\211\346\240\221\344\270\255\347\232\204\346\234\200\345\244\247\350\267\257\345\276\204\345\222\214.md"
index c0a8db4a..71e642e3 100644
--- "a/Solutions/0124. \344\272\214\345\217\211\346\240\221\344\270\255\347\232\204\346\234\200\345\244\247\350\267\257\345\276\204\345\222\214.md"
+++ "b/Solutions/0124. \344\272\214\345\217\211\346\240\221\344\270\255\347\232\204\346\234\200\345\244\247\350\267\257\345\276\204\345\222\214.md"
@@ -22,7 +22,7 @@

-```Python
+```python
输入:root = [1,2,3]
输出:6
解释:最优路径是 2 -> 1 -> 3 ,路径和为 2 + 1 + 3 = 6
@@ -32,7 +32,7 @@

-```Python
+```python
输入:root = [-10,9,20,null,null,15,7]
输出:42
解释:最优路径是 15 -> 20 -> 7 ,路径和为 15 + 20 + 7 = 42
@@ -73,7 +73,7 @@
### 思路 1:代码
-```Python
+```python
# Definition for a binary tree node.
# class TreeNode:
# def __init__(self, val=0, left=None, right=None):
diff --git "a/Solutions/0125. \351\252\214\350\257\201\345\233\236\346\226\207\344\270\262.md" "b/Solutions/0125. \351\252\214\350\257\201\345\233\236\346\226\207\344\270\262.md"
index 004c37f1..a004e5eb 100644
--- "a/Solutions/0125. \351\252\214\350\257\201\345\233\236\346\226\207\344\270\262.md"
+++ "b/Solutions/0125. \351\252\214\350\257\201\345\233\236\346\226\207\344\270\262.md"
@@ -19,7 +19,7 @@
- 示例 1:
-```Python
+```python
输入: "A man, a plan, a canal: Panama"
输出:true
解释:"amanaplanacanalpanama" 是回文串。
@@ -27,7 +27,7 @@
- 示例 2:
-```Python
+```python
输入:"race a car"
输出:false
解释:"raceacar" 不是回文串。
@@ -46,7 +46,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def isPalindrome(self, s: str) -> bool:
left = 0
diff --git "a/Solutions/0127. \345\215\225\350\257\215\346\216\245\351\276\231.md" "b/Solutions/0127. \345\215\225\350\257\215\346\216\245\351\276\231.md"
index 0bb424a3..950ac389 100644
--- "a/Solutions/0127. \345\215\225\350\257\215\346\216\245\351\276\231.md"
+++ "b/Solutions/0127. \345\215\225\350\257\215\346\216\245\351\276\231.md"
@@ -22,7 +22,7 @@
## 代码
-```Python
+```python
class Solution:
def ladderLength(self, beginWord: str, endWord: str, wordList: List[str]) -> int:
if not wordList or endWord not in wordList:
diff --git "a/Solutions/0128. \346\234\200\351\225\277\350\277\236\347\273\255\345\272\217\345\210\227.md" "b/Solutions/0128. \346\234\200\351\225\277\350\277\236\347\273\255\345\272\217\345\210\227.md"
index 5f3aa474..1bc37af8 100644
--- "a/Solutions/0128. \346\234\200\351\225\277\350\277\236\347\273\255\345\272\217\345\210\227.md"
+++ "b/Solutions/0128. \346\234\200\351\225\277\350\277\236\347\273\255\345\272\217\345\210\227.md"
@@ -18,7 +18,7 @@
- 示例 1:
-```Python
+```python
输入:nums = [100,4,200,1,3,2]
输出:4
解释:最长数字连续序列是 [1, 2, 3, 4]。它的长度为 4。
@@ -26,7 +26,7 @@
- 示例 2:
-```Python
+```python
输入:nums = [0,3,7,2,5,8,4,6,0,1]
输出:9
```
@@ -49,7 +49,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def longestConsecutive(self, nums: List[int]) -> int:
ans = 0
diff --git "a/Solutions/0129. \346\261\202\346\240\271\350\212\202\347\202\271\345\210\260\345\217\266\350\212\202\347\202\271\346\225\260\345\255\227\344\271\213\345\222\214.md" "b/Solutions/0129. \346\261\202\346\240\271\350\212\202\347\202\271\345\210\260\345\217\266\350\212\202\347\202\271\346\225\260\345\255\227\344\271\213\345\222\214.md"
index 133f505c..49225cd8 100644
--- "a/Solutions/0129. \346\261\202\346\240\271\350\212\202\347\202\271\345\210\260\345\217\266\350\212\202\347\202\271\346\225\260\345\255\227\344\271\213\345\222\214.md"
+++ "b/Solutions/0129. \346\261\202\346\240\271\350\212\202\347\202\271\345\210\260\345\217\266\350\212\202\347\202\271\346\225\260\345\255\227\344\271\213\345\222\214.md"
@@ -22,7 +22,7 @@

-```Python
+```python
输入:root = [1,2,3]
输出:25
解释:
@@ -35,7 +35,7 @@

-```Python
+```python
输入:root = [4,9,0,5,1]
输出:1026
解释:
@@ -55,7 +55,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def dfs(self, root, pre_total):
if not root:
diff --git "a/Solutions/0130. \350\242\253\345\233\264\347\273\225\347\232\204\345\214\272\345\237\237.md" "b/Solutions/0130. \350\242\253\345\233\264\347\273\225\347\232\204\345\214\272\345\237\237.md"
index 2c4ecbe3..8737f777 100644
--- "a/Solutions/0130. \350\242\253\345\233\264\347\273\225\347\232\204\345\214\272\345\237\237.md"
+++ "b/Solutions/0130. \350\242\253\345\233\264\347\273\225\347\232\204\345\214\272\345\237\237.md"
@@ -22,7 +22,7 @@

-```Python
+```python
输入:board = [["X","X","X","X"],["X","O","O","X"],["X","X","O","X"],["X","O","X","X"]]
输出:[["X","X","X","X"],["X","X","X","X"],["X","X","X","X"],["X","O","X","X"]]
解释:被围绕的区间不会存在于边界上,换句话说,任何边界上的 'O' 都不会被填充为 'X'。 任何不在边界上,或不与边界上的 'O' 相连的 'O' 最终都会被填充为 'X'。如果两个元素在水平或垂直方向相邻,则称它们是“相连”的。
@@ -30,7 +30,7 @@
- 示例 2:
-```Python
+```python
输入:board = [["X"]]
输出:[["X"]]
```
@@ -47,7 +47,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def solve(self, board: List[List[str]]) -> None:
"""
diff --git "a/Solutions/0131. \345\210\206\345\211\262\345\233\236\346\226\207\344\270\262.md" "b/Solutions/0131. \345\210\206\345\211\262\345\233\236\346\226\207\344\270\262.md"
index 2c57a728..d09962c4 100644
--- "a/Solutions/0131. \345\210\206\345\211\262\345\233\236\346\226\207\344\270\262.md"
+++ "b/Solutions/0131. \345\210\206\345\211\262\345\233\236\346\226\207\344\270\262.md"
@@ -24,7 +24,7 @@
## 代码
-```Python
+```python
class Solution:
res = []
path = []
diff --git "a/Solutions/0133. \345\205\213\351\232\206\345\233\276.md" "b/Solutions/0133. \345\205\213\351\232\206\345\233\276.md"
index 5728cc26..dbe6d960 100644
--- "a/Solutions/0133. \345\205\213\351\232\206\345\233\276.md"
+++ "b/Solutions/0133. \345\205\213\351\232\206\345\233\276.md"
@@ -23,7 +23,7 @@

-```Python
+```python
输入:adjList = [[2,4],[1,3],[2,4],[1,3]]
输出:[[2,4],[1,3],[2,4],[1,3]]
解释:
@@ -38,7 +38,7 @@

-```Python
+```python
输入:adjList = [[2],[1]]
输出:[[2],[1]]
```
@@ -60,7 +60,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def cloneGraph(self, node: 'Node') -> 'Node':
if not node:
@@ -99,7 +99,7 @@ class Solution:
### 思路 2:代码
-```Python
+```python
class Solution:
def cloneGraph(self, node: 'Node') -> 'Node':
if not node:
diff --git "a/Solutions/0134. \345\212\240\346\262\271\347\253\231.md" "b/Solutions/0134. \345\212\240\346\262\271\347\253\231.md"
index 5d09f517..f9cad2f5 100644
--- "a/Solutions/0134. \345\212\240\346\262\271\347\253\231.md"
+++ "b/Solutions/0134. \345\212\240\346\262\271\347\253\231.md"
@@ -29,7 +29,7 @@
## 代码
-```Python
+```python
class Solution:
def canCompleteCircuit(self, gas: List[int], cost: List[int]) -> int:
sum_diff, min_sum = 0, float('inf')
diff --git "a/Solutions/0135. \345\210\206\345\217\221\347\263\226\346\236\234.md" "b/Solutions/0135. \345\210\206\345\217\221\347\263\226\346\236\234.md"
index 246f54a5..99693544 100644
--- "a/Solutions/0135. \345\210\206\345\217\221\347\263\226\346\236\234.md"
+++ "b/Solutions/0135. \345\210\206\345\217\221\347\263\226\346\236\234.md"
@@ -24,7 +24,7 @@
- 示例 1:
-```Python
+```python
输入:ratings = [1,0,2]
输出:5
解释:你可以分别给第一个、第二个、第三个孩子分发 2、1、2 颗糖果。
@@ -32,7 +32,7 @@
- 示例 2:
-```Python
+```python
输入:ratings = [1,2,2]
输出:4
解释:你可以分别给第一个、第二个、第三个孩子分发 1、2、1 颗糖果。
@@ -60,7 +60,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def candy(self, ratings: List[int]) -> int:
size = len(ratings)
diff --git "a/Solutions/0136. \345\217\252\345\207\272\347\216\260\344\270\200\346\254\241\347\232\204\346\225\260\345\255\227.md" "b/Solutions/0136. \345\217\252\345\207\272\347\216\260\344\270\200\346\254\241\347\232\204\346\225\260\345\255\227.md"
index 843bcdda..2480ea23 100644
--- "a/Solutions/0136. \345\217\252\345\207\272\347\216\260\344\270\200\346\254\241\347\232\204\346\225\260\345\255\227.md"
+++ "b/Solutions/0136. \345\217\252\345\207\272\347\216\260\344\270\200\346\254\241\347\232\204\346\225\260\345\255\227.md"
@@ -17,14 +17,14 @@
- 示例 1:
-```Python
+```python
输入: [2,2,1]
输出: 1
```
- 示例 2:
-```Python
+```python
输入: [4,1,2,1,2]
输出: 4
```
@@ -47,7 +47,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def singleNumber(self, nums: List[int]) -> int:
if len(nums) == 1:
diff --git "a/Solutions/0137. \345\217\252\345\207\272\347\216\260\344\270\200\346\254\241\347\232\204\346\225\260\345\255\227 II.md" "b/Solutions/0137. \345\217\252\345\207\272\347\216\260\344\270\200\346\254\241\347\232\204\346\225\260\345\255\227 II.md"
index f39f59bc..8896c5fb 100644
--- "a/Solutions/0137. \345\217\252\345\207\272\347\216\260\344\270\200\346\254\241\347\232\204\346\225\260\345\255\227 II.md"
+++ "b/Solutions/0137. \345\217\252\345\207\272\347\216\260\344\270\200\346\254\241\347\232\204\346\225\260\345\255\227 II.md"
@@ -19,14 +19,14 @@
- 示例 1:
-```Python
+```python
输入:nums = [2,2,3,2]
输出:3
```
- 示例 2:
-```Python
+```python
输入:nums = [0,1,0,1,0,1,99]
输出:99
```
@@ -40,7 +40,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def singleNumber(self, nums: List[int]) -> int:
nums_dict = dict()
@@ -71,7 +71,7 @@ class Solution:
### 思路 2:代码
-```Python
+```python
class Solution:
def singleNumber(self, nums: List[int]) -> int:
ans = 0
diff --git "a/Solutions/0138. \345\244\215\345\210\266\345\270\246\351\232\217\346\234\272\346\214\207\351\222\210\347\232\204\351\223\276\350\241\250.md" "b/Solutions/0138. \345\244\215\345\210\266\345\270\246\351\232\217\346\234\272\346\214\207\351\222\210\347\232\204\351\223\276\350\241\250.md"
index 8c6cdaea..8b0dc838 100644
--- "a/Solutions/0138. \345\244\215\345\210\266\345\270\246\351\232\217\346\234\272\346\214\207\351\222\210\347\232\204\351\223\276\350\241\250.md"
+++ "b/Solutions/0138. \345\244\215\345\210\266\345\270\246\351\232\217\346\234\272\346\214\207\351\222\210\347\232\204\351\223\276\350\241\250.md"
@@ -21,7 +21,7 @@

-```Python
+```python
输入:head = [[7,null],[13,0],[11,4],[10,2],[1,0]]
输出:[[7,null],[13,0],[11,4],[10,2],[1,0]]
```
@@ -30,7 +30,7 @@

-```Python
+```python
输入:head = [[1,1],[2,1]]
输出:[[1,1],[2,1]]
```
@@ -44,7 +44,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def copyRandomList(self, head: 'Node') -> 'Node':
if not head:
diff --git "a/Solutions/0139. \345\215\225\350\257\215\346\213\206\345\210\206.md" "b/Solutions/0139. \345\215\225\350\257\215\346\213\206\345\210\206.md"
index fbb8073e..057ae04a 100644
--- "a/Solutions/0139. \345\215\225\350\257\215\346\213\206\345\210\206.md"
+++ "b/Solutions/0139. \345\215\225\350\257\215\346\213\206\345\210\206.md"
@@ -22,7 +22,7 @@
- 示例 1:
-```Python
+```python
输入: s = "leetcode", wordDict = ["leet", "code"]
输出: true
解释: 返回 true 因为 "leetcode" 可以由 "leet" 和 "code" 拼接成。
@@ -30,7 +30,7 @@
- 示例 2:
-```Python
+```python
输入: s = "applepenapple", wordDict = ["apple", "pen"]
输出: true
解释: 返回 true 因为 "applepenapple" 可以由 "apple" "pen" "apple" 拼接成。
@@ -69,7 +69,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def wordBreak(self, s: str, wordDict: List[str]) -> bool:
size = len(s)
diff --git "a/Solutions/0140. \345\215\225\350\257\215\346\213\206\345\210\206 II.md" "b/Solutions/0140. \345\215\225\350\257\215\346\213\206\345\210\206 II.md"
index 9d11563b..5ca99a10 100644
--- "a/Solutions/0140. \345\215\225\350\257\215\346\213\206\345\210\206 II.md"
+++ "b/Solutions/0140. \345\215\225\350\257\215\346\213\206\345\210\206 II.md"
@@ -24,7 +24,7 @@
## 代码
-```Python
+```python
class Solution:
def wordBreak(self, s: str, wordDict: List[str]) -> List[str]:
size = len(s)
diff --git "a/Solutions/0141. \347\216\257\345\275\242\351\223\276\350\241\250.md" "b/Solutions/0141. \347\216\257\345\275\242\351\223\276\350\241\250.md"
index 6d48cd55..b6cc241d 100644
--- "a/Solutions/0141. \347\216\257\345\275\242\351\223\276\350\241\250.md"
+++ "b/Solutions/0141. \347\216\257\345\275\242\351\223\276\350\241\250.md"
@@ -21,7 +21,7 @@

-```Python
+```python
输入:head = [3,2,0,-4], pos = 1
输出:True
解释:链表中有一个环,其尾部连接到第二个节点。
@@ -31,7 +31,7 @@

-```Python
+```python
输入:head = [1,2], pos = 0
输出:True
解释:链表中有一个环,其尾部连接到第一个节点。
@@ -45,7 +45,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def hasCycle(self, head: ListNode) -> bool:
nodeset = set()
@@ -71,7 +71,7 @@ class Solution:
### 思路 2:代码
-```Python
+```python
class Solution:
def hasCycle(self, head: ListNode) -> bool:
if head == None or head.next == None:
diff --git "a/Solutions/0142. \347\216\257\345\275\242\351\223\276\350\241\250 II.md" "b/Solutions/0142. \347\216\257\345\275\242\351\223\276\350\241\250 II.md"
index 324215d1..634fae6a 100644
--- "a/Solutions/0142. \347\216\257\345\275\242\351\223\276\350\241\250 II.md"
+++ "b/Solutions/0142. \347\216\257\345\275\242\351\223\276\350\241\250 II.md"
@@ -21,7 +21,7 @@

-```Python
+```python
输入:head = [3,2,0,-4], pos = 1
输出:返回索引为 1 的链表节点
解释:链表中有一个环,其尾部连接到第二个节点。
@@ -31,7 +31,7 @@

-```Python
+```python
输入:head = [1,2], pos = 0
输出:返回索引为 0 的链表节点
解释:链表中有一个环,其尾部连接到第一个节点。
@@ -54,7 +54,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def detectCycle(self, head: ListNode) -> ListNode:
fast, slow = head, head
diff --git "a/Solutions/0143. \351\207\215\346\216\222\351\223\276\350\241\250.md" "b/Solutions/0143. \351\207\215\346\216\222\351\223\276\350\241\250.md"
index 3eab56bd..daeb8e5a 100644
--- "a/Solutions/0143. \351\207\215\346\216\222\351\223\276\350\241\250.md"
+++ "b/Solutions/0143. \351\207\215\346\216\222\351\223\276\350\241\250.md"
@@ -19,7 +19,7 @@

-```Python
+```python
输入:head = [1,2,3,4]
输出:[1,4,2,3]
```
@@ -28,7 +28,7 @@

-```Python
+```python
输入:head = [1,2,3,4,5]
输出:[1,5,2,4,3]
```
@@ -41,7 +41,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def reorderList(self, head: ListNode) -> None:
"""
diff --git "a/Solutions/0144. \344\272\214\345\217\211\346\240\221\347\232\204\345\211\215\345\272\217\351\201\215\345\216\206.md" "b/Solutions/0144. \344\272\214\345\217\211\346\240\221\347\232\204\345\211\215\345\272\217\351\201\215\345\216\206.md"
index a9a90c19..3b63da6c 100644
--- "a/Solutions/0144. \344\272\214\345\217\211\346\240\221\347\232\204\345\211\215\345\272\217\351\201\215\345\216\206.md"
+++ "b/Solutions/0144. \344\272\214\345\217\211\346\240\221\347\232\204\345\211\215\345\272\217\351\201\215\345\216\206.md"
@@ -20,7 +20,7 @@

-```Python
+```python
输入:root = [1,null,2,3]
输出:[1,2,3]
```
@@ -29,7 +29,7 @@

-```Python
+```python
输入:root = [1,null,2]
输出:[1,2]
```
@@ -47,7 +47,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def preorderTraversal(self, root: TreeNode) -> List[int]:
res = []
@@ -85,7 +85,7 @@ class Solution:
### 思路 2:代码
-```Python
+```python
class Solution:
def preorderTraversal(self, root: Optional[TreeNode]) -> List[int]:
if not root: # 二叉树为空直接返回
diff --git "a/Solutions/0145. \344\272\214\345\217\211\346\240\221\347\232\204\345\220\216\345\272\217\351\201\215\345\216\206.md" "b/Solutions/0145. \344\272\214\345\217\211\346\240\221\347\232\204\345\220\216\345\272\217\351\201\215\345\216\206.md"
index ca9895b0..e13c818b 100644
--- "a/Solutions/0145. \344\272\214\345\217\211\346\240\221\347\232\204\345\220\216\345\272\217\351\201\215\345\216\206.md"
+++ "b/Solutions/0145. \344\272\214\345\217\211\346\240\221\347\232\204\345\220\216\345\272\217\351\201\215\345\216\206.md"
@@ -20,14 +20,14 @@

-```Python
+```python
输入:root = [1,null,2,3]
输出:[3,2,1]
```
- 示例 2:
-```Python
+```python
输入:root = []
输出:[]
```
@@ -45,7 +45,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def postorderTraversal(self, root: TreeNode) -> List[int]:
res = []
@@ -85,7 +85,7 @@ class Solution:
### 思路 2:代码
-```Python
+```python
class Solution:
def postorderTraversal(self, root: Optional[TreeNode]) -> List[int]:
res = []
diff --git "a/Solutions/0147. \345\257\271\351\223\276\350\241\250\350\277\233\350\241\214\346\217\222\345\205\245\346\216\222\345\272\217.md" "b/Solutions/0147. \345\257\271\351\223\276\350\241\250\350\277\233\350\241\214\346\217\222\345\205\245\346\216\222\345\272\217.md"
index 0494da25..f0e3eb44 100644
--- "a/Solutions/0147. \345\257\271\351\223\276\350\241\250\350\277\233\350\241\214\346\217\222\345\205\245\346\216\222\345\272\217.md"
+++ "b/Solutions/0147. \345\257\271\351\223\276\350\241\250\350\277\233\350\241\214\346\217\222\345\205\245\346\216\222\345\272\217.md"
@@ -24,7 +24,7 @@

-```Python
+```python
输入: head = [4,2,1,3]
输出: [1,2,3,4]
```
@@ -33,7 +33,7 @@

-```Python
+```python
输入: head = [-1,5,3,4,0]
输出: [-1,0,3,4,5]
```
@@ -56,7 +56,7 @@
### 思路 1:代码
-```Python
+```python
def insertionSortList(self, head: ListNode) -> ListNode:
if not head or not head.next:
diff --git "a/Solutions/0148. \346\216\222\345\272\217\351\223\276\350\241\250.md" "b/Solutions/0148. \346\216\222\345\272\217\351\223\276\350\241\250.md"
index b05bd5d8..7d19dcb6 100644
--- "a/Solutions/0148. \346\216\222\345\272\217\351\223\276\350\241\250.md"
+++ "b/Solutions/0148. \346\216\222\345\272\217\351\223\276\350\241\250.md"
@@ -20,7 +20,7 @@

-```Python
+```python
输入:head = [4,2,1,3]
输出:[1,2,3,4]
```
@@ -29,7 +29,7 @@

-```Python
+```python
输入:head = [-1,5,3,4,0]
输出:[-1,0,3,4,5]
```
@@ -52,7 +52,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def bubbleSort(self, head: ListNode):
node_i = head
@@ -92,7 +92,7 @@ class Solution:
### 思路 2:代码
-```Python
+```python
class Solution:
def sectionSort(self, head: ListNode):
node_i = head
@@ -136,7 +136,7 @@ class Solution:
### 思路 3:代码
-```Python
+```python
class Solution:
def insertionSort(self, head: ListNode):
if not head or not head.next:
@@ -187,7 +187,7 @@ class Solution:
### 思路 4:代码
-```Python
+```python
class Solution:
def merge(self, left, right):
# 归并环节
@@ -248,7 +248,7 @@ class Solution:
### 思路 5:代码
-```Python
+```python
class Solution:
def partition(self, left: ListNode, right: ListNode):
# 左闭右开,区间没有元素或者只有一个元素,直接返回第一个节点
@@ -302,7 +302,7 @@ class Solution:
### 思路 6:代码
-```Python
+```python
class Solution:
def countingSort(self, head: ListNode):
if not head:
@@ -355,7 +355,7 @@ class Solution:
### 思路 7:代码
-```Python
+```python
class ListNode:
def __init__(self, val=0, next=None):
self.val = val
@@ -468,7 +468,7 @@ class Solution:
### 思路 8:代码
-```Python
+```python
class Solution:
def radixSort(self, head: ListNode):
# 计算位数最长的位数
diff --git "a/Solutions/0149. \347\233\264\347\272\277\344\270\212\346\234\200\345\244\232\347\232\204\347\202\271\346\225\260.md" "b/Solutions/0149. \347\233\264\347\272\277\344\270\212\346\234\200\345\244\232\347\232\204\347\202\271\346\225\260.md"
index 765a9420..7c98ae64 100644
--- "a/Solutions/0149. \347\233\264\347\272\277\344\270\212\346\234\200\345\244\232\347\232\204\347\202\271\346\225\260.md"
+++ "b/Solutions/0149. \347\233\264\347\272\277\344\270\212\346\234\200\345\244\232\347\232\204\347\202\271\346\225\260.md"
@@ -23,7 +23,7 @@
## 代码
-```Python
+```python
class Solution:
def maxPoints(self, points: List[List[int]]) -> int:
n = len(points)
diff --git "a/Solutions/0150. \351\200\206\346\263\242\345\205\260\350\241\250\350\276\276\345\274\217\346\261\202\345\200\274.md" "b/Solutions/0150. \351\200\206\346\263\242\345\205\260\350\241\250\350\276\276\345\274\217\346\261\202\345\200\274.md"
index 2bba7128..43bc11ef 100644
--- "a/Solutions/0150. \351\200\206\346\263\242\345\205\260\350\241\250\350\276\276\345\274\217\346\261\202\345\200\274.md"
+++ "b/Solutions/0150. \351\200\206\346\263\242\345\205\260\350\241\250\350\276\276\345\274\217\346\261\202\345\200\274.md"
@@ -21,7 +21,7 @@
- 示例 1:
-```Python
+```python
输入:tokens = ["4","13","5","/","+"]
输出:6
解释:该算式转化为常见的中缀算术表达式为:(4 + (13 / 5)) = 6
@@ -29,7 +29,7 @@
- 示例 2:
-```Python
+```python
输入:tokens = ["10","6","9","3","+","-11","*","/","*","17","+","5","+"]
输出:22
解释:该算式转化为常见的中缀算术表达式为:
@@ -61,7 +61,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def evalRPN(self, tokens: List[str]) -> int:
stack = []
diff --git "a/Solutions/0151. \345\217\215\350\275\254\345\255\227\347\254\246\344\270\262\344\270\255\347\232\204\345\215\225\350\257\215.md" "b/Solutions/0151. \345\217\215\350\275\254\345\255\227\347\254\246\344\270\262\344\270\255\347\232\204\345\215\225\350\257\215.md"
index 890f5207..7d34abfc 100644
--- "a/Solutions/0151. \345\217\215\350\275\254\345\255\227\347\254\246\344\270\262\344\270\255\347\232\204\345\215\225\350\257\215.md"
+++ "b/Solutions/0151. \345\217\215\350\275\254\345\255\227\347\254\246\344\270\262\344\270\255\347\232\204\345\215\225\350\257\215.md"
@@ -22,7 +22,7 @@
- 示例 1:
-```Python
+```python
输入:s = " hello world "
输出:"world hello"
解释:反转后的字符串中不能存在前导空格和尾随空格。
@@ -30,7 +30,7 @@
- 示例 2:
-```Python
+```python
输入:s = "a good example"
输出:"example good a"
解释:如果两个单词间有多余的空格,反转后的字符串需要将单词间的空格减少到仅有一个。
@@ -44,7 +44,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def reverseWords(self, s: str) -> str:
return " ".join(reversed(s.split()))
@@ -71,7 +71,7 @@ class Solution:
### 思路 2:代码
-```Python
+```python
class Solution:
def reverseWords(self, s: str) -> str:
words = []
diff --git "a/Solutions/0152. \344\271\230\347\247\257\346\234\200\345\244\247\345\255\220\346\225\260\347\273\204.md" "b/Solutions/0152. \344\271\230\347\247\257\346\234\200\345\244\247\345\255\220\346\225\260\347\273\204.md"
index dc9038f3..c99fcd93 100644
--- "a/Solutions/0152. \344\271\230\347\247\257\346\234\200\345\244\247\345\255\220\346\225\260\347\273\204.md"
+++ "b/Solutions/0152. \344\271\230\347\247\257\346\234\200\345\244\247\345\255\220\346\225\260\347\273\204.md"
@@ -21,7 +21,7 @@
- 示例 1:
-```Python
+```python
输入: nums = [2,3,-2,4]
输出: 6
解释: 子数组 [2,3] 有最大乘积 6。
@@ -29,7 +29,7 @@
- 示例 2:
-```Python
+```python
输入: nums = [-2,0,-1]
输出: 0
解释: 结果不能为 2, 因为 [-2,-1] 不是子数组。
@@ -71,7 +71,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def maxProduct(self, nums: List[int]) -> int:
size = len(nums)
@@ -97,7 +97,7 @@ class Solution:
### 思路 2:代码
-```Python
+```python
class Solution:
def maxProduct(self, nums: List[int]) -> int:
size = len(nums)
diff --git "a/Solutions/0153. \345\257\273\346\211\276\346\227\213\350\275\254\346\216\222\345\272\217\346\225\260\347\273\204\344\270\255\347\232\204\346\234\200\345\260\217\345\200\274.md" "b/Solutions/0153. \345\257\273\346\211\276\346\227\213\350\275\254\346\216\222\345\272\217\346\225\260\347\273\204\344\270\255\347\232\204\346\234\200\345\260\217\345\200\274.md"
index 97bb75e6..17d589eb 100644
--- "a/Solutions/0153. \345\257\273\346\211\276\346\227\213\350\275\254\346\216\222\345\272\217\346\225\260\347\273\204\344\270\255\347\232\204\346\234\200\345\260\217\345\200\274.md"
+++ "b/Solutions/0153. \345\257\273\346\211\276\346\227\213\350\275\254\346\216\222\345\272\217\346\225\260\347\273\204\344\270\255\347\232\204\346\234\200\345\260\217\345\200\274.md"
@@ -22,7 +22,7 @@
- 示例 1:
-```Python
+```python
输入:nums = [3,4,5,1,2]
输出:1
解释:原数组为 [1,2,3,4,5] ,旋转 3 次得到输入数组。
@@ -30,7 +30,7 @@
- 示例 2:
-```Python
+```python
输入:nums = [4,5,6,7,0,1,2]
输出:0
解释:原数组为 [0,1,2,4,5,6,7] ,旋转 4 次得到输入数组。
@@ -44,7 +44,7 @@
第一种的最小值在最左边。第二种最小值在第二段升序序列的第一个元素。
-```Python
+```python
*
*
*
@@ -53,7 +53,7 @@
*
```
-```Python
+```python
*
*
*
@@ -71,7 +71,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def findMin(self, nums: List[int]) -> int:
left = 0
diff --git "a/Solutions/0154. \345\257\273\346\211\276\346\227\213\350\275\254\346\216\222\345\272\217\346\225\260\347\273\204\344\270\255\347\232\204\346\234\200\345\260\217\345\200\274 II.md" "b/Solutions/0154. \345\257\273\346\211\276\346\227\213\350\275\254\346\216\222\345\272\217\346\225\260\347\273\204\344\270\255\347\232\204\346\234\200\345\260\217\345\200\274 II.md"
index 6330a3ce..c27d2266 100644
--- "a/Solutions/0154. \345\257\273\346\211\276\346\227\213\350\275\254\346\216\222\345\272\217\346\225\260\347\273\204\344\270\255\347\232\204\346\234\200\345\260\217\345\200\274 II.md"
+++ "b/Solutions/0154. \345\257\273\346\211\276\346\227\213\350\275\254\346\216\222\345\272\217\346\225\260\347\273\204\344\270\255\347\232\204\346\234\200\345\260\217\345\200\274 II.md"
@@ -47,7 +47,7 @@
## 代码
-```Python
+```python
class Solution:
def findMin(self, nums: List[int]) -> int:
left = 0
diff --git "a/Solutions/0155. \346\234\200\345\260\217\346\240\210.md" "b/Solutions/0155. \346\234\200\345\260\217\346\240\210.md"
index b24daa1f..f48b7e99 100644
--- "a/Solutions/0155. \346\234\200\345\260\217\346\240\210.md"
+++ "b/Solutions/0155. \346\234\200\345\260\217\346\240\210.md"
@@ -17,7 +17,7 @@
- 示例 1:
-```Python
+```python
输入:
["MinStack","push","push","push","getMin","pop","top","getMin"]
[[],[-2],[0],[-3],[],[],[],[]]
@@ -51,7 +51,7 @@ minStack.getMin(); --> 返回 -2.
### 思路 1:代码
-```Python
+```python
class MinStack:
def __init__(self):
@@ -93,7 +93,7 @@ class MinStack:
### 思路 2:代码
-```Python
+```python
class MinStack:
def __init__(self):
"""
diff --git "a/Solutions/0159. \350\207\263\345\244\232\345\214\205\345\220\253\344\270\244\344\270\252\344\270\215\345\220\214\345\255\227\347\254\246\347\232\204\346\234\200\351\225\277\345\255\220\344\270\262.md" "b/Solutions/0159. \350\207\263\345\244\232\345\214\205\345\220\253\344\270\244\344\270\252\344\270\215\345\220\214\345\255\227\347\254\246\347\232\204\346\234\200\351\225\277\345\255\220\344\270\262.md"
index 958c401e..7116e678 100644
--- "a/Solutions/0159. \350\207\263\345\244\232\345\214\205\345\220\253\344\270\244\344\270\252\344\270\215\345\220\214\345\255\227\347\254\246\347\232\204\346\234\200\351\225\277\345\255\220\344\270\262.md"
+++ "b/Solutions/0159. \350\207\263\345\244\232\345\214\205\345\220\253\344\270\244\344\270\252\344\270\215\345\220\214\345\255\227\347\254\246\347\232\204\346\234\200\351\225\277\345\255\220\344\270\262.md"
@@ -21,7 +21,7 @@ left,right 指向字符串开始位置。
## 代码
-```Python
+```python
import collections
class Solution:
def lengthOfLongestSubstringTwoDistinct(self, s: str) -> int:
diff --git "a/Solutions/0160. \347\233\270\344\272\244\351\223\276\350\241\250.md" "b/Solutions/0160. \347\233\270\344\272\244\351\223\276\350\241\250.md"
index 0f4dccdf..ae0f6ec0 100644
--- "a/Solutions/0160. \347\233\270\344\272\244\351\223\276\350\241\250.md"
+++ "b/Solutions/0160. \347\233\270\344\272\244\351\223\276\350\241\250.md"
@@ -26,7 +26,7 @@

-```Python
+```python
输入:intersectVal = 8, listA = [4,1,8,4,5], listB = [5,6,1,8,4,5], skipA = 2, skipB = 3
输出:Intersected at '8'
解释:相交节点的值为 8 (注意,如果两个链表相交则不能为 0)。
@@ -39,7 +39,7 @@

-```Python
+```python
输入:intersectVal = 2, listA = [1,9,1,2,4], listB = [3,2,4], skipA = 3, skipB = 1
输出:Intersected at '2'
解释:相交节点的值为 2 (注意,如果两个链表相交则不能为 0)。
@@ -67,7 +67,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def getIntersectionNode(self, headA: ListNode, headB: ListNode) -> ListNode:
if headA == None or headB == None:
diff --git "a/Solutions/0162. \345\257\273\346\211\276\345\263\260\345\200\274.md" "b/Solutions/0162. \345\257\273\346\211\276\345\263\260\345\200\274.md"
index 3f8a1209..c88b66da 100644
--- "a/Solutions/0162. \345\257\273\346\211\276\345\263\260\345\200\274.md"
+++ "b/Solutions/0162. \345\257\273\346\211\276\345\263\260\345\200\274.md"
@@ -22,7 +22,7 @@
- 示例 1:
-```Python
+```python
输入:nums = [1,2,3,1]
输出:2
解释:3 是峰值元素,你的函数应该返回其索引 2。
@@ -30,7 +30,7 @@
- 示例 2:
-```Python
+```python
输入:nums = [1,2,1,3,5,6,4]
输出:1 或 5
解释:你的函数可以返回索引 1,其峰值元素为 2;或者返回索引 5, 其峰值元素为 6。
@@ -48,7 +48,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def findPeakElement(self, nums: List[int]) -> int:
left = 0
diff --git "a/Solutions/0164. \346\234\200\345\244\247\351\227\264\350\267\235.md" "b/Solutions/0164. \346\234\200\345\244\247\351\227\264\350\267\235.md"
index c737e826..f6be1e49 100644
--- "a/Solutions/0164. \346\234\200\345\244\247\351\227\264\350\267\235.md"
+++ "b/Solutions/0164. \346\234\200\345\244\247\351\227\264\350\267\235.md"
@@ -18,7 +18,7 @@
- 示例 1:
-```Python
+```python
输入: nums = [3,6,9,1]
输出: 3
解释: 排序后的数组是 [1,3,6,9], 其中相邻元素 (3,6) 和 (6,9) 之间都存在最大差值 3。
@@ -26,7 +26,7 @@
- 示例 2:
-```Python
+```python
输入: nums = [10]
输出: 0
解释: 数组元素个数小于 2,因此返回 0。
@@ -54,7 +54,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def radixSort(self, arr):
size = len(str(max(arr)))
diff --git "a/Solutions/0166. \345\210\206\346\225\260\345\210\260\345\260\217\346\225\260.md" "b/Solutions/0166. \345\210\206\346\225\260\345\210\260\345\260\217\346\225\260.md"
index 146f252b..f6bcd122 100644
--- "a/Solutions/0166. \345\210\206\346\225\260\345\210\260\345\260\217\346\225\260.md"
+++ "b/Solutions/0166. \345\210\206\346\225\260\345\210\260\345\260\217\346\225\260.md"
@@ -21,7 +21,7 @@
## 代码
-```Python
+```python
class Solution:
def fractionToDecimal(self, numerator: int, denominator: int) -> str:
if numerator == 0:
diff --git "a/Solutions/0167. \344\270\244\346\225\260\344\271\213\345\222\214 II - \350\276\223\345\205\245\346\234\211\345\272\217\346\225\260\347\273\204.md" "b/Solutions/0167. \344\270\244\346\225\260\344\271\213\345\222\214 II - \350\276\223\345\205\245\346\234\211\345\272\217\346\225\260\347\273\204.md"
index 81301433..51813a36 100644
--- "a/Solutions/0167. \344\270\244\346\225\260\344\271\213\345\222\214 II - \350\276\223\345\205\245\346\234\211\345\272\217\346\225\260\347\273\204.md"
+++ "b/Solutions/0167. \344\270\244\346\225\260\344\271\213\345\222\214 II - \350\276\223\345\205\245\346\234\211\345\272\217\346\225\260\347\273\204.md"
@@ -21,7 +21,7 @@
- 示例 1:
-```Python
+```python
输入:numbers = [2,7,11,15], target = 9
输出:[1,2]
解释:2 与 7 之和等于目标数 9 。因此 index1 = 1, index2 = 2 。返回 [1, 2] 。
@@ -29,7 +29,7 @@
- 示例 2:
-```Python
+```python
输入:numbers = [2,3,4], target = 6
输出:[1,3]
解释:2 与 4 之和等于目标数 6 。因此 index1 = 1, index2 = 3 。返回 [1, 3] 。
@@ -39,7 +39,7 @@
这道题如果暴力遍历数组,从中找到相加之和等于 `target` 的两个数,时间复杂度为 $O(n^2)$,可以尝试一下。
-```Python
+```python
class Solution:
def twoSum(self, numbers: List[int], target: int) -> List[int]:
size = len(numbers)
@@ -67,7 +67,7 @@ class Solution:
### 思路 1:代码
-```Python
+```python
class Solution:
def twoSum(self, numbers: List[int], target: int) -> List[int]:
for i in range(len(numbers)):
@@ -103,7 +103,7 @@ class Solution:
### 思路 2:代码
-```Python
+```python
class Solution:
def twoSum(self, numbers: List[int], target: int) -> List[int]:
left = 0
diff --git "a/Solutions/0168. Excel\350\241\250\345\210\227\345\220\215\347\247\260.md" "b/Solutions/0168. Excel\350\241\250\345\210\227\345\220\215\347\247\260.md"
index e39da78c..ed896e7b 100644
--- "a/Solutions/0168. Excel\350\241\250\345\210\227\345\220\215\347\247\260.md"
+++ "b/Solutions/0168. Excel\350\241\250\345\210\227\345\220\215\347\247\260.md"
@@ -17,7 +17,7 @@
## 代码
-```Python
+```python
class Solution:
def convertToTitle(self, columnNumber: int) -> str:
s = ""
diff --git "a/Solutions/0169. \345\244\232\346\225\260\345\205\203\347\264\240.md" "b/Solutions/0169. \345\244\232\346\225\260\345\205\203\347\264\240.md"
index 35e44434..b636f82a 100644
--- "a/Solutions/0169. \345\244\232\346\225\260\345\205\203\347\264\240.md"
+++ "b/Solutions/0169. \345\244\232\346\225\260\345\205\203\347\264\240.md"
@@ -19,14 +19,14 @@
- 示例 1:
-```Python
+```python
输入:nums = [3,2,3]
输出:3
```
- 示例 2:
-```Python
+```python
输入:nums = [2,2,1,1,1,2,2]
输出:2
```
@@ -41,7 +41,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def majorityElement(self, nums: List[int]) -> int:
numDict = dict()
@@ -80,7 +80,7 @@ class Solution:
### 思路 2:代码
-```Python
+```python
class Solution:
def majorityElement(self, nums: List[int]) -> int:
def get_mode(low, high):
diff --git "a/Solutions/0170. \344\270\244\346\225\260\344\271\213\345\222\214 III - \346\225\260\346\215\256\347\273\223\346\236\204\350\256\276\350\256\241.md" "b/Solutions/0170. \344\270\244\346\225\260\344\271\213\345\222\214 III - \346\225\260\346\215\256\347\273\223\346\236\204\350\256\276\350\256\241.md"
index e510ade3..d2f1e4d9 100644
--- "a/Solutions/0170. \344\270\244\346\225\260\344\271\213\345\222\214 III - \346\225\260\346\215\256\347\273\223\346\236\204\350\256\276\350\256\241.md"
+++ "b/Solutions/0170. \344\270\244\346\225\260\344\271\213\345\222\214 III - \346\225\260\346\215\256\347\273\223\346\236\204\350\256\276\350\256\241.md"
@@ -23,7 +23,7 @@
## 代码
-```Python
+```python
class TwoSum:
def __init__(self):
diff --git "a/Solutions/0171. Excel \350\241\250\345\210\227\345\272\217\345\217\267.md" "b/Solutions/0171. Excel \350\241\250\345\210\227\345\272\217\345\217\267.md"
index a4b187fe..8cacceb2 100644
--- "a/Solutions/0171. Excel \350\241\250\345\210\227\345\272\217\345\217\267.md"
+++ "b/Solutions/0171. Excel \350\241\250\345\210\227\345\272\217\345\217\267.md"
@@ -20,7 +20,7 @@ Excel 表的列名称由大写字母组成,共有 26 个,因此列名称的
## 代码
-```Python
+```python
class Solution:
def titleToNumber(self, columnTitle: str) -> int:
ans = 0
diff --git "a/Solutions/0172. \351\230\266\344\271\230\345\220\216\347\232\204\351\233\266.md" "b/Solutions/0172. \351\230\266\344\271\230\345\220\216\347\232\204\351\233\266.md"
index 3f975eee..1febd45b 100644
--- "a/Solutions/0172. \351\230\266\344\271\230\345\220\216\347\232\204\351\233\266.md"
+++ "b/Solutions/0172. \351\230\266\344\271\230\345\220\216\347\232\204\351\233\266.md"
@@ -17,7 +17,7 @@
## 代码
-```Python
+```python
class Solution:
def trailingZeroes(self, n: int) -> int:
count = 0
diff --git "a/Solutions/0173. \344\272\214\345\217\211\346\220\234\347\264\242\346\240\221\350\277\255\344\273\243\345\231\250.md" "b/Solutions/0173. \344\272\214\345\217\211\346\220\234\347\264\242\346\240\221\350\277\255\344\273\243\345\231\250.md"
index a2c12068..3007767c 100644
--- "a/Solutions/0173. \344\272\214\345\217\211\346\220\234\347\264\242\346\240\221\350\277\255\344\273\243\345\231\250.md"
+++ "b/Solutions/0173. \344\272\214\345\217\211\346\220\234\347\264\242\346\240\221\350\277\255\344\273\243\345\231\250.md"
@@ -21,7 +21,7 @@
## 代码
-```Python
+```python
class BSTIterator:
def __init__(self, root: TreeNode):
diff --git "a/Solutions/0179. \346\234\200\345\244\247\346\225\260.md" "b/Solutions/0179. \346\234\200\345\244\247\346\225\260.md"
index 8095174c..f2681d25 100644
--- "a/Solutions/0179. \346\234\200\345\244\247\346\225\260.md"
+++ "b/Solutions/0179. \346\234\200\345\244\247\346\225\260.md"
@@ -18,14 +18,14 @@
- 示例 1:
-```Python
+```python
输入:nums = [10,2]
输出:"210"
```
- 示例 2:
-```Python
+```python
输入:nums = [3,30,34,5,9]
输出:"9534330"
```
@@ -40,7 +40,7 @@
### 思路 1:代码
-```Python
+```python
import functools
class Solution:
diff --git "a/Solutions/0188. \344\271\260\345\215\226\350\202\241\347\245\250\347\232\204\346\234\200\344\275\263\346\227\266\346\234\272 IV.md" "b/Solutions/0188. \344\271\260\345\215\226\350\202\241\347\245\250\347\232\204\346\234\200\344\275\263\346\227\266\346\234\272 IV.md"
index acb06441..0dec06fa 100644
--- "a/Solutions/0188. \344\271\260\345\215\226\350\202\241\347\245\250\347\232\204\346\234\200\344\275\263\346\227\266\346\234\272 IV.md"
+++ "b/Solutions/0188. \344\271\260\345\215\226\350\202\241\347\245\250\347\232\204\346\234\200\344\275\263\346\227\266\346\234\272 IV.md"
@@ -67,7 +67,7 @@
## 代码
-```Python
+```python
class Solution:
def maxProfit(self, k: int, prices: List[int]) -> int:
size = len(prices)
diff --git "a/Solutions/0189. \350\275\256\350\275\254\346\225\260\347\273\204.md" "b/Solutions/0189. \350\275\256\350\275\254\346\225\260\347\273\204.md"
index 99386ef3..87b46bb0 100644
--- "a/Solutions/0189. \350\275\256\350\275\254\346\225\260\347\273\204.md"
+++ "b/Solutions/0189. \350\275\256\350\275\254\346\225\260\347\273\204.md"
@@ -20,7 +20,7 @@
- 示例 1:
-```Python
+```python
输入:nums = [1,2,3,4,5,6,7], k = 3
输出:[5,6,7,1,2,3,4]
解释:
@@ -45,7 +45,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def rotate(self, nums: List[int], k: int) -> None:
n = len(nums)
diff --git "a/Solutions/0190. \351\242\240\345\200\222\344\272\214\350\277\233\345\210\266\344\275\215.md" "b/Solutions/0190. \351\242\240\345\200\222\344\272\214\350\277\233\345\210\266\344\275\215.md"
index 2842619d..fe7dc599 100644
--- "a/Solutions/0190. \351\242\240\345\200\222\344\272\214\350\277\233\345\210\266\344\275\215.md"
+++ "b/Solutions/0190. \351\242\240\345\200\222\344\272\214\350\277\233\345\210\266\344\275\215.md"
@@ -17,7 +17,7 @@
- 示例 1:
-```Python
+```python
输入:n = 00000010100101000001111010011100
输出:964176192 (00111001011110000010100101000000)
解释:输入的二进制串 00000010100101000001111010011100 表示无符号整数 43261596,
@@ -26,7 +26,7 @@
- 示例 2:
-```Python
+```python
输入:n = 11111111111111111111111111111101
输出:3221225471 (10111111111111111111111111111111)
解释:输入的二进制串 11111111111111111111111111111101 表示无符号整数 4294967293,
@@ -43,7 +43,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def reverseBits(self, n: int) -> int:
res = 0
diff --git "a/Solutions/0191. \344\275\2151\347\232\204\344\270\252\346\225\260.md" "b/Solutions/0191. \344\275\2151\347\232\204\344\270\252\346\225\260.md"
index f1be12af..18a712af 100644
--- "a/Solutions/0191. \344\275\2151\347\232\204\344\270\252\346\225\260.md"
+++ "b/Solutions/0191. \344\275\2151\347\232\204\344\270\252\346\225\260.md"
@@ -17,7 +17,7 @@
- 示例 1:
-```Python
+```python
输入:n = 00000000000000000000000000001011
输出:3
解释:输入的二进制串 00000000000000000000000000001011 中,共有三位为 '1'。
@@ -25,7 +25,7 @@
- 示例 2:
-```Python
+```python
输入:n = 00000000000000000000000010000000
输出:1
解释:输入的二进制串 00000000000000000000000010000000 中,共有一位为 '1'。
@@ -39,7 +39,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def hammingWeight(self, n: int) -> int:
ans = 0
@@ -64,7 +64,7 @@ class Solution:
### 思路 2:代码
-```Python
+```python
class Solution:
def hammingWeight(self, n: int) -> int:
ans = 0
diff --git "a/Solutions/0198. \346\211\223\345\256\266\345\212\253\350\210\215.md" "b/Solutions/0198. \346\211\223\345\256\266\345\212\253\350\210\215.md"
index df39837f..097a58b3 100644
--- "a/Solutions/0198. \346\211\223\345\256\266\345\212\253\350\210\215.md"
+++ "b/Solutions/0198. \346\211\223\345\256\266\345\212\253\350\210\215.md"
@@ -18,7 +18,7 @@
- 示例 1:
-```Python
+```python
输入:[1,2,3,1]
输出:4
解释:偷窃 1 号房屋 (金额 = 1) ,然后偷窃 3 号房屋 (金额 = 3)。
@@ -27,7 +27,7 @@
- 示例 2:
-```Python
+```python
输入:[2,7,9,3,1]
输出:12
解释:偷窃 1 号房屋 (金额 = 2), 偷窃 3 号房屋 (金额 = 9),接着偷窃 5 号房屋 (金额 = 1)。
@@ -70,7 +70,7 @@ $dp[i] = \begin{cases} nums[0] & i = 1 \cr max(dp[i - 2] + nums[i - 1], dp[i - 1
### 思路 1:代码
-```Python
+```python
class Solution:
def rob(self, nums: List[int]) -> int:
size = len(nums)
diff --git "a/Solutions/0199. \344\272\214\345\217\211\346\240\221\347\232\204\345\217\263\350\247\206\345\233\276.md" "b/Solutions/0199. \344\272\214\345\217\211\346\240\221\347\232\204\345\217\263\350\247\206\345\233\276.md"
index c5e955bc..9f3714cd 100644
--- "a/Solutions/0199. \344\272\214\345\217\211\346\240\221\347\232\204\345\217\263\350\247\206\345\233\276.md"
+++ "b/Solutions/0199. \344\272\214\345\217\211\346\240\221\347\232\204\345\217\263\350\247\206\345\233\276.md"
@@ -20,14 +20,14 @@

-```Python
+```python
输入: [1,2,3,null,5,null,4]
输出: [1,3,4]
```
- 示例 2:
-```Python
+```python
输入: [1,null,3]
输出: [1,3]
```
@@ -40,7 +40,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def rightSideView(self, root: TreeNode) -> List[int]:
if not root:
diff --git "a/Solutions/0200. \345\262\233\345\261\277\346\225\260\351\207\217.md" "b/Solutions/0200. \345\262\233\345\261\277\346\225\260\351\207\217.md"
index 7c66f5c9..62e77d8c 100644
--- "a/Solutions/0200. \345\262\233\345\261\277\346\225\260\351\207\217.md"
+++ "b/Solutions/0200. \345\262\233\345\261\277\346\225\260\351\207\217.md"
@@ -22,7 +22,7 @@
- 示例 1:
-```Python
+```python
输入:grid = [
["1","1","1","1","0"],
["1","1","0","1","0"],
@@ -34,7 +34,7 @@
- 示例 2:
-```Python
+```python
输入:grid = [
["1","1","0","0","0"],
["1","1","0","0","0"],
@@ -60,7 +60,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def dfs(self, grid, i, j):
n = len(grid)
diff --git "a/Solutions/0201. \346\225\260\345\255\227\350\214\203\345\233\264\346\214\211\344\275\215\344\270\216.md" "b/Solutions/0201. \346\225\260\345\255\227\350\214\203\345\233\264\346\214\211\344\275\215\344\270\216.md"
index 7232313f..fbccef57 100644
--- "a/Solutions/0201. \346\225\260\345\255\227\350\214\203\345\233\264\346\214\211\344\275\215\344\270\216.md"
+++ "b/Solutions/0201. \346\225\260\345\255\227\350\214\203\345\233\264\346\214\211\344\275\215\344\270\216.md"
@@ -17,14 +17,14 @@
- 示例 1:
-```Python
+```python
输入:left = 5, right = 7
输出:4
```
- 示例 2:
-```Python
+```python
输入:left = 1, right = 2147483647
输出:0
```
@@ -77,7 +77,7 @@
### 思路 1:位运算代码
-```Python
+```python
class Solution:
def rangeBitwiseAnd(self, left: int, right: int) -> int:
while left < right:
diff --git "a/Solutions/0202. \345\277\253\344\271\220\346\225\260.md" "b/Solutions/0202. \345\277\253\344\271\220\346\225\260.md"
index 0a33c581..fdebc689 100644
--- "a/Solutions/0202. \345\277\253\344\271\220\346\225\260.md"
+++ "b/Solutions/0202. \345\277\253\344\271\220\346\225\260.md"
@@ -19,7 +19,7 @@
## 代码
-```Python
+```python
class Solution:
def getNext(self, n: int):
total_sum = 0
diff --git "a/Solutions/0203. \347\247\273\351\231\244\351\223\276\350\241\250\345\205\203\347\264\240.md" "b/Solutions/0203. \347\247\273\351\231\244\351\223\276\350\241\250\345\205\203\347\264\240.md"
index 684feb75..e5f1fafb 100644
--- "a/Solutions/0203. \347\247\273\351\231\244\351\223\276\350\241\250\345\205\203\347\264\240.md"
+++ "b/Solutions/0203. \347\247\273\351\231\244\351\223\276\350\241\250\345\205\203\347\264\240.md"
@@ -21,14 +21,14 @@

-```Python
+```python
输入:head = [1,2,6,3,4,5,6], val = 6
输出:[1,2,3,4,5]
```
- 示例 2:
-```Python
+```python
输入:head = [], val = 1
输出:[]
```
@@ -45,7 +45,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def removeElements(self, head: ListNode, val: int) -> ListNode:
newHead = ListNode(0, head)
diff --git "a/Solutions/0204. \350\256\241\346\225\260\350\264\250\346\225\260.md" "b/Solutions/0204. \350\256\241\346\225\260\350\264\250\346\225\260.md"
index b6219c60..115fb64f 100644
--- "a/Solutions/0204. \350\256\241\346\225\260\350\264\250\346\225\260.md"
+++ "b/Solutions/0204. \350\256\241\346\225\260\350\264\250\346\225\260.md"
@@ -17,7 +17,7 @@
- 示例 1:
-```Python
+```python
输入 n = 10
输出 4
解释 小于 10 的质数一共有 4 个, 它们是 2, 3, 5, 7。
@@ -25,7 +25,7 @@
- 示例 2:
-```Python
+```python
输入:n = 1
输出:0
```
@@ -46,7 +46,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def isPrime(self, x):
for i in range(2, int(pow(x, 0.5)) + 1):
@@ -80,7 +80,7 @@ class Solution:
### 思路 2:代码
-```Python
+```python
class Solution:
def countPrimes(self, n: int) -> int:
is_prime = [True] * n
diff --git "a/Solutions/0205. \345\220\214\346\236\204\345\255\227\347\254\246\344\270\262.md" "b/Solutions/0205. \345\220\214\346\236\204\345\255\227\347\254\246\344\270\262.md"
index 4335dd96..649fc21a 100644
--- "a/Solutions/0205. \345\220\214\346\236\204\345\255\227\347\254\246\344\270\262.md"
+++ "b/Solutions/0205. \345\220\214\346\236\204\345\255\227\347\254\246\344\270\262.md"
@@ -17,7 +17,7 @@
## 代码
-```Python
+```python
class Solution:
def isIsomorphic(self, s: str, t: str) -> bool:
s_dict = dict()
diff --git "a/Solutions/0206. \345\217\215\350\275\254\351\223\276\350\241\250.md" "b/Solutions/0206. \345\217\215\350\275\254\351\223\276\350\241\250.md"
index 8a55696c..aba16e38 100644
--- "a/Solutions/0206. \345\217\215\350\275\254\351\223\276\350\241\250.md"
+++ "b/Solutions/0206. \345\217\215\350\275\254\351\223\276\350\241\250.md"
@@ -18,7 +18,7 @@
- 示例 1:
-```Python
+```python
输入:head = [1,2,3,4,5]
输出:[5,4,3,2,1]
解释:
@@ -46,7 +46,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def reverseList(self, head: ListNode) -> ListNode:
pre = None
@@ -82,7 +82,7 @@ class Solution:
### 思路 2:代码
-```Python
+```python
class Solution:
def reverseList(self, head: ListNode) -> ListNode:
if head == None or head.next == None:
diff --git "a/Solutions/0207. \350\257\276\347\250\213\350\241\250.md" "b/Solutions/0207. \350\257\276\347\250\213\350\241\250.md"
index 110b99d1..aa0c035f 100644
--- "a/Solutions/0207. \350\257\276\347\250\213\350\241\250.md"
+++ "b/Solutions/0207. \350\257\276\347\250\213\350\241\250.md"
@@ -21,7 +21,7 @@
- 示例 1:
-```Python
+```python
输入:numCourses = 2, prerequisites = [[1,0]]
输出:true
解释:总共有 2 门课程。学习课程 1 之前,你需要完成课程 0。这是可能的。
@@ -29,7 +29,7 @@
- 示例 2:
-```Python
+```python
输入:numCourses = 2, prerequisites = [[1,0],[0,1]]
输出:false
解释:总共有 2 门课程。学习课程 1 之前,你需要先完成课程 0;并且学习课程 0 之前,你还应先完成课程 1。这是不可能的。
@@ -48,7 +48,7 @@
### 思路 1:代码
-```Python
+```python
import collections
class Solution:
diff --git "a/Solutions/0208. \345\256\236\347\216\260 Trie (\345\211\215\347\274\200\346\240\221).md" "b/Solutions/0208. \345\256\236\347\216\260 Trie (\345\211\215\347\274\200\346\240\221).md"
index 746765dd..3275a58f 100644
--- "a/Solutions/0208. \345\256\236\347\216\260 Trie (\345\211\215\347\274\200\346\240\221).md"
+++ "b/Solutions/0208. \345\256\236\347\216\260 Trie (\345\211\215\347\274\200\346\240\221).md"
@@ -24,7 +24,7 @@
- 示例 1:
-```Python
+```python
输入:
["Trie", "insert", "search", "search", "startsWith", "insert", "search"]
[[], ["apple"], ["apple"], ["app"], ["app"], ["app"], ["app"]]
@@ -65,7 +65,7 @@ trie.search("app"); // 返回 True
### 思路 1:代码
-```Python
+```python
class Node:
def __init__(self):
self.children = dict()
diff --git "a/Solutions/0209. \351\225\277\345\272\246\346\234\200\345\260\217\347\232\204\345\255\220\346\225\260\347\273\204.md" "b/Solutions/0209. \351\225\277\345\272\246\346\234\200\345\260\217\347\232\204\345\255\220\346\225\260\347\273\204.md"
index 7ab50867..f12dff0b 100644
--- "a/Solutions/0209. \351\225\277\345\272\246\346\234\200\345\260\217\347\232\204\345\255\220\346\225\260\347\273\204.md"
+++ "b/Solutions/0209. \351\225\277\345\272\246\346\234\200\345\260\217\347\232\204\345\255\220\346\225\260\347\273\204.md"
@@ -19,7 +19,7 @@
- 示例 1:
-```Python
+```python
输入:target = 7, nums = [2,3,1,2,4,3]
输出:2
解释:子数组 [4,3] 是该条件下的长度最小的子数组。
@@ -27,7 +27,7 @@
- 示例 2:
-```Python
+```python
输入:target = 4, nums = [1,4,4]
输出:1
```
@@ -48,7 +48,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def minSubArrayLen(self, target: int, nums: List[int]) -> int:
size = len(nums)
diff --git "a/Solutions/0210. \350\257\276\347\250\213\350\241\250 II.md" "b/Solutions/0210. \350\257\276\347\250\213\350\241\250 II.md"
index cc2d7a8b..009d8fbd 100644
--- "a/Solutions/0210. \350\257\276\347\250\213\350\241\250 II.md"
+++ "b/Solutions/0210. \350\257\276\347\250\213\350\241\250 II.md"
@@ -22,7 +22,7 @@
- 示例 1:
-```Python
+```python
输入:numCourses = 2, prerequisites = [[1,0]]
输出:[0,1]
解释:总共有 2 门课程。要学习课程 1,你需要先完成课程 0。因此,正确的课程顺序为 [0,1]。
@@ -30,7 +30,7 @@
- 示例 2:
-```Python
+```python
输入:numCourses = 4, prerequisites = [[1,0],[2,0],[3,1],[3,2]]
输出:[0,2,1,3]
解释:总共有 4 门课程。要学习课程 3,你应该先完成课程 1 和课程 2。并且课程 1 和课程 2 都应该排在课程 0 之后。
@@ -52,7 +52,7 @@
### 思路 1:代码
-```Python
+```python
import collections
class Solution:
diff --git "a/Solutions/0211. \346\267\273\345\212\240\344\270\216\346\220\234\347\264\242\345\215\225\350\257\215 - \346\225\260\346\215\256\347\273\223\346\236\204\350\256\276\350\256\241.md" "b/Solutions/0211. \346\267\273\345\212\240\344\270\216\346\220\234\347\264\242\345\215\225\350\257\215 - \346\225\260\346\215\256\347\273\223\346\236\204\350\256\276\350\256\241.md"
index 56f264e5..5ad7c810 100644
--- "a/Solutions/0211. \346\267\273\345\212\240\344\270\216\346\220\234\347\264\242\345\215\225\350\257\215 - \346\225\260\346\215\256\347\273\223\346\236\204\350\256\276\350\256\241.md"
+++ "b/Solutions/0211. \346\267\273\345\212\240\344\270\216\346\220\234\347\264\242\345\215\225\350\257\215 - \346\225\260\346\215\256\347\273\223\346\236\204\350\256\276\350\256\241.md"
@@ -24,7 +24,7 @@
- 示例 1:
-```Python
+```python
输入:
["WordDictionary","addWord","addWord","addWord","search","search","search","search"]
[[],["bad"],["dad"],["mad"],["pad"],["bad"],[".ad"],["b.."]]
@@ -57,7 +57,7 @@ wordDictionary.search("b.."); // 返回 True
### 思路 1:代码
-```Python
+```python
class Trie:
def __init__(self):
diff --git "a/Solutions/0212. \345\215\225\350\257\215\346\220\234\347\264\242 II.md" "b/Solutions/0212. \345\215\225\350\257\215\346\220\234\347\264\242 II.md"
index f42d7562..088adfb5 100644
--- "a/Solutions/0212. \345\215\225\350\257\215\346\220\234\347\264\242 II.md"
+++ "b/Solutions/0212. \345\215\225\350\257\215\346\220\234\347\264\242 II.md"
@@ -25,7 +25,7 @@
## 代码
-```Python
+```python
class Trie:
def __init__(self):
diff --git "a/Solutions/0213. \346\211\223\345\256\266\345\212\253\350\210\215 II.md" "b/Solutions/0213. \346\211\223\345\256\266\345\212\253\350\210\215 II.md"
index bde47834..2aa1e49f 100644
--- "a/Solutions/0213. \346\211\223\345\256\266\345\212\253\350\210\215 II.md"
+++ "b/Solutions/0213. \346\211\223\345\256\266\345\212\253\350\210\215 II.md"
@@ -18,7 +18,7 @@
- 示例 1:
-```Python
+```python
输入:nums = [2,3,2]
输出:3
解释:你不能先偷窃 1 号房屋(金额 = 2),然后偷窃 3 号房屋(金额 = 2), 因为他们是相邻的。
@@ -26,7 +26,7 @@
- 示例 2:
-```Python
+```python
输入:nums = [1,2,3,1]
输出:4
解释:你可以先偷窃 1 号房屋(金额 = 1),然后偷窃 3 号房屋(金额 = 3)。偷窃到的最高金额 = 1 + 3 = 4。
@@ -76,7 +76,7 @@ $dp[i] = \begin{cases} nums[0] & i = 1 \cr max(dp[i - 2] + nums[i - 1], dp[i - 1
### 思路 1:动态规划代码
-```Python
+```python
class Solution:
def helper(self, nums):
size = len(nums)
diff --git "a/Solutions/0215. \346\225\260\347\273\204\344\270\255\347\232\204\347\254\254K\344\270\252\346\234\200\345\244\247\345\205\203\347\264\240.md" "b/Solutions/0215. \346\225\260\347\273\204\344\270\255\347\232\204\347\254\254K\344\270\252\346\234\200\345\244\247\345\205\203\347\264\240.md"
index 1b070ce4..38e94055 100644
--- "a/Solutions/0215. \346\225\260\347\273\204\344\270\255\347\232\204\347\254\254K\344\270\252\346\234\200\345\244\247\345\205\203\347\264\240.md"
+++ "b/Solutions/0215. \346\225\260\347\273\204\344\270\255\347\232\204\347\254\254K\344\270\252\346\234\200\345\244\247\345\205\203\347\264\240.md"
@@ -19,14 +19,14 @@
- 示例 1:
-```Python
+```python
输入: [3,2,1,5,6,4], k = 2
输出: 5
```
- 示例 2:
-```Python
+```python
输入: [3,2,3,1,2,4,5,5,6], k = 4
输出: 4
```
@@ -58,7 +58,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def findKthLargest(self, nums: List[int], k: int) -> int:
# 调整为大顶堆
@@ -110,7 +110,7 @@ class Solution:
### 思路 2:代码
-```Python
+```python
import random
class Solution:
@@ -171,7 +171,7 @@ class Solution:
### 思路 3:代码
-```Python
+```python
class Solution:
def findKthLargest(self, nums: List[int], k: int) -> int:
nums.sort()
@@ -194,7 +194,7 @@ class Solution:
### 思路 4:代码
-```Python
+```python
import heapq
class Solution:
def findKthLargest(self, nums: List[int], k: int) -> int:
diff --git "a/Solutions/0217. \345\255\230\345\234\250\351\207\215\345\244\215\345\205\203\347\264\240.md" "b/Solutions/0217. \345\255\230\345\234\250\351\207\215\345\244\215\345\205\203\347\264\240.md"
index 4d9287c3..ca03782c 100644
--- "a/Solutions/0217. \345\255\230\345\234\250\351\207\215\345\244\215\345\205\203\347\264\240.md"
+++ "b/Solutions/0217. \345\255\230\345\234\250\351\207\215\345\244\215\345\205\203\347\264\240.md"
@@ -18,14 +18,14 @@
- 示例 1:
-```Python
+```python
输入:nums = [1,2,3,1]
输出:True
```
- 示例 2:
-```Python
+```python
输入:nums = [1,2,3,4]
输出:False
```
@@ -40,7 +40,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def containsDuplicate(self, nums: List[int]) -> bool:
numDict = dict()
@@ -65,7 +65,7 @@ class Solution:
### 思路 2:集合代码
-```Python
+```python
class Solution:
def containsDuplicate(self, nums: List[int]) -> bool:
return len(set(nums)) != len(nums)
@@ -85,7 +85,7 @@ class Solution:
### 思路 3:排序代码
-```Python
+```python
class Solution:
def containsDuplicate(self, nums: List[int]) -> bool:
nums.sort()
diff --git "a/Solutions/0218. \345\244\251\351\231\205\347\272\277\351\227\256\351\242\230.md" "b/Solutions/0218. \345\244\251\351\231\205\347\272\277\351\227\256\351\242\230.md"
index 6860fb12..fd9174c1 100644
--- "a/Solutions/0218. \345\244\251\351\231\205\347\272\277\351\227\256\351\242\230.md"
+++ "b/Solutions/0218. \345\244\251\351\231\205\347\272\277\351\227\256\351\242\230.md"
@@ -49,7 +49,7 @@
## 代码
-```Python
+```python
from sortedcontainers import SortedList
class Solution:
diff --git "a/Solutions/0219. \345\255\230\345\234\250\351\207\215\345\244\215\345\205\203\347\264\240 II.md" "b/Solutions/0219. \345\255\230\345\234\250\351\207\215\345\244\215\345\205\203\347\264\240 II.md"
index 356fd53a..c00438b5 100644
--- "a/Solutions/0219. \345\255\230\345\234\250\351\207\215\345\244\215\345\205\203\347\264\240 II.md"
+++ "b/Solutions/0219. \345\255\230\345\234\250\351\207\215\345\244\215\345\205\203\347\264\240 II.md"
@@ -19,7 +19,7 @@
- 示例 1:
-```Python
+```python
输入:nums = [1,2,3,1], k = 3
输出:True
```
@@ -38,7 +38,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def containsNearbyDuplicate(self, nums: List[int], k: int) -> bool:
nums_dict = dict()
diff --git "a/Solutions/0220. \345\255\230\345\234\250\351\207\215\345\244\215\345\205\203\347\264\240 III.md" "b/Solutions/0220. \345\255\230\345\234\250\351\207\215\345\244\215\345\205\203\347\264\240 III.md"
index da3083fb..d9df8e74 100644
--- "a/Solutions/0220. \345\255\230\345\234\250\351\207\215\345\244\215\345\205\203\347\264\240 III.md"
+++ "b/Solutions/0220. \345\255\230\345\234\250\351\207\215\345\244\215\345\205\203\347\264\240 III.md"
@@ -20,14 +20,14 @@
- 示例 1:
-```Python
+```python
输入:nums = [1,2,3,1], k = 3, t = 0
输出:True
```
- 示例 2:
-```Python
+```python
输入:nums = [1,0,1,1], k = 1, t = 2
输出:True
```
@@ -60,7 +60,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def containsNearbyAlmostDuplicate(self, nums: List[int], k: int, t: int) -> bool:
bucket_dict = dict()
@@ -112,7 +112,7 @@ class Solution:
### 思路 2:代码
-```Python
+```python
from sortedcontainers import SortedList
class Solution:
diff --git "a/Solutions/0221. \346\234\200\345\244\247\346\255\243\346\226\271\345\275\242.md" "b/Solutions/0221. \346\234\200\345\244\247\346\255\243\346\226\271\345\275\242.md"
index 84fa5383..6d34487e 100644
--- "a/Solutions/0221. \346\234\200\345\244\247\346\255\243\346\226\271\345\275\242.md"
+++ "b/Solutions/0221. \346\234\200\345\244\247\346\255\243\346\226\271\345\275\242.md"
@@ -22,7 +22,7 @@

-```Python
+```python
输入:matrix = [["1","0","1","0","0"],["1","0","1","1","1"],["1","1","1","1","1"],["1","0","0","1","0"]]
输出:4
```
@@ -31,7 +31,7 @@

-```Python
+```python
输入:matrix = [["0","1"],["1","0"]]
输出:1
```
@@ -65,7 +65,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def maximalSquare(self, matrix: List[List[str]]) -> int:
rows, cols = len(matrix), len(matrix[0])
diff --git "a/Solutions/0222. \345\256\214\345\205\250\344\272\214\345\217\211\346\240\221\347\232\204\350\212\202\347\202\271\344\270\252\346\225\260.md" "b/Solutions/0222. \345\256\214\345\205\250\344\272\214\345\217\211\346\240\221\347\232\204\350\212\202\347\202\271\344\270\252\346\225\260.md"
index 93a56dfb..44649f6a 100644
--- "a/Solutions/0222. \345\256\214\345\205\250\344\272\214\345\217\211\346\240\221\347\232\204\350\212\202\347\202\271\344\270\252\346\225\260.md"
+++ "b/Solutions/0222. \345\256\214\345\205\250\344\272\214\345\217\211\346\240\221\347\232\204\350\212\202\347\202\271\344\270\252\346\225\260.md"
@@ -17,7 +17,7 @@
## 代码
-```Python
+```python
class Solution:
def countNodes(self, root: TreeNode) -> int:
if not root:
diff --git "a/Solutions/0223. \347\237\251\345\275\242\351\235\242\347\247\257.md" "b/Solutions/0223. \347\237\251\345\275\242\351\235\242\347\247\257.md"
index 5d816181..d891d67e 100644
--- "a/Solutions/0223. \347\237\251\345\275\242\351\235\242\347\247\257.md"
+++ "b/Solutions/0223. \347\237\251\345\275\242\351\235\242\347\247\257.md"
@@ -17,7 +17,7 @@
## 代码
-```Python
+```python
class Solution:
def computeArea(self, ax1: int, ay1: int, ax2: int, ay2: int, bx1: int, by1: int, bx2: int, by2: int) -> int:
area_a = (ax2 - ax1) * (ay2 - ay1)
diff --git "a/Solutions/0225. \347\224\250\351\230\237\345\210\227\345\256\236\347\216\260\346\240\210.md" "b/Solutions/0225. \347\224\250\351\230\237\345\210\227\345\256\236\347\216\260\346\240\210.md"
index 6b508248..8aa684ad 100644
--- "a/Solutions/0225. \347\224\250\351\230\237\345\210\227\345\256\236\347\216\260\346\240\210.md"
+++ "b/Solutions/0225. \347\224\250\351\230\237\345\210\227\345\256\236\347\216\260\346\240\210.md"
@@ -23,7 +23,7 @@
- 示例 1:
-```Python
+```python
输入:
["MyStack", "push", "push", "top", "pop", "empty"]
[[], [1], [2], [], [], []]
@@ -52,7 +52,7 @@ myStack.empty(); // 返回 False
### 思路 1:代码
-```Python
+```python
class MyStack:
def __init__(self):
diff --git "a/Solutions/0226. \347\277\273\350\275\254\344\272\214\345\217\211\346\240\221.md" "b/Solutions/0226. \347\277\273\350\275\254\344\272\214\345\217\211\346\240\221.md"
index 70f58af0..1c5098f8 100644
--- "a/Solutions/0226. \347\277\273\350\275\254\344\272\214\345\217\211\346\240\221.md"
+++ "b/Solutions/0226. \347\277\273\350\275\254\344\272\214\345\217\211\346\240\221.md"
@@ -20,7 +20,7 @@

-```Python
+```python
输入:root = [4,2,7,1,3,6,9]
输出:[4,7,2,9,6,3,1]
```
@@ -29,7 +29,7 @@

-```Python
+```python
输入:root = [2,1,3]
输出:[2,3,1]
```
@@ -53,7 +53,7 @@
2. 书写递归主体:
- ```Python
+ ```python
left = self.invertTree(root.left)
right = self.invertTree(root.right)
root.left = right
@@ -67,7 +67,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def invertTree(self, root: Optional[TreeNode]) -> Optional[TreeNode]:
if not root:
diff --git "a/Solutions/0227. \345\237\272\346\234\254\350\256\241\347\256\227\345\231\250 II.md" "b/Solutions/0227. \345\237\272\346\234\254\350\256\241\347\256\227\345\231\250 II.md"
index 2b998efd..51c1b998 100644
--- "a/Solutions/0227. \345\237\272\346\234\254\350\256\241\347\256\227\345\231\250 II.md"
+++ "b/Solutions/0227. \345\237\272\346\234\254\350\256\241\347\256\227\345\231\250 II.md"
@@ -21,14 +21,14 @@
- 示例 1:
-```Python
+```python
输入:s = "3+2*2"
输出:7
```
- 示例 2:
-```Python
+```python
输入:s = " 3/2 "
输出:1
```
@@ -54,7 +54,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def calculate(self, s: str) -> int:
size = len(s)
diff --git "a/Solutions/0231. 2 \347\232\204\345\271\202.md" "b/Solutions/0231. 2 \347\232\204\345\271\202.md"
index 7861522e..1049d92f 100644
--- "a/Solutions/0231. 2 \347\232\204\345\271\202.md"
+++ "b/Solutions/0231. 2 \347\232\204\345\271\202.md"
@@ -17,7 +17,7 @@
- 示例 1:
-```Python
+```python
输入:n = 1
输出:True
解释:2^0 = 1
@@ -25,7 +25,7 @@
- 示例 2:
-```Python
+```python
输入:n = 16
输出:True
解释:2^4 = 16
@@ -42,7 +42,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def isPowerOfTwo(self, n: int) -> bool:
if n <= 0:
@@ -66,7 +66,7 @@ class Solution:
### 思路 2:代码
-```Python
+```python
class Solution:
def isPowerOfTwo(self, n: int) -> bool:
return n > 0 and 1073741824 % n == 0
diff --git "a/Solutions/0232. \347\224\250\346\240\210\345\256\236\347\216\260\351\230\237\345\210\227.md" "b/Solutions/0232. \347\224\250\346\240\210\345\256\236\347\216\260\351\230\237\345\210\227.md"
index d8a0f9de..2e10bc9e 100644
--- "a/Solutions/0232. \347\224\250\346\240\210\345\256\236\347\216\260\351\230\237\345\210\227.md"
+++ "b/Solutions/0232. \347\224\250\346\240\210\345\256\236\347\216\260\351\230\237\345\210\227.md"
@@ -27,7 +27,7 @@
- 示例 1:
-```Python
+```python
输入:
["MyQueue", "push", "push", "peek", "pop", "empty"]
[[], [1], [2], [], [], []]
@@ -56,7 +56,7 @@ myQueue.empty(); // return false
### 思路 1:代码
-```Python
+```python
class MyQueue:
def __init__(self):
diff --git "a/Solutions/0233. \346\225\260\345\255\227 1 \347\232\204\344\270\252\346\225\260.md" "b/Solutions/0233. \346\225\260\345\255\227 1 \347\232\204\344\270\252\346\225\260.md"
index f46d70e9..618ad95d 100644
--- "a/Solutions/0233. \346\225\260\345\255\227 1 \347\232\204\344\270\252\346\225\260.md"
+++ "b/Solutions/0233. \346\225\260\345\255\227 1 \347\232\204\344\270\252\346\225\260.md"
@@ -17,14 +17,14 @@
- 示例 1:
-```Python
+```python
输入:n = 13
输出:6
```
- 示例 2:
-```Python
+```python
输入:n = 0
输出:0
```
@@ -53,7 +53,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def countDigitOne(self, n: int) -> int:
# 将 n 转换为字符串 s
diff --git "a/Solutions/0234. \345\233\236\346\226\207\351\223\276\350\241\250.md" "b/Solutions/0234. \345\233\236\346\226\207\351\223\276\350\241\250.md"
index 0747c48c..7ca5b395 100644
--- "a/Solutions/0234. \345\233\236\346\226\207\351\223\276\350\241\250.md"
+++ "b/Solutions/0234. \345\233\236\346\226\207\351\223\276\350\241\250.md"
@@ -20,7 +20,7 @@

-```Python
+```python
输入:head = [1,2,2,1]
输出:True
```
@@ -29,7 +29,7 @@

-```Python
+```python
输入:head = [1,2]
输出:False
```
@@ -44,7 +44,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def isPalindrome(self, head: ListNode) -> bool:
nodes = []
diff --git "a/Solutions/0235. \344\272\214\345\217\211\346\220\234\347\264\242\346\240\221\347\232\204\346\234\200\350\277\221\345\205\254\345\205\261\347\245\226\345\205\210.md" "b/Solutions/0235. \344\272\214\345\217\211\346\220\234\347\264\242\346\240\221\347\232\204\346\234\200\350\277\221\345\205\254\345\205\261\347\245\226\345\205\210.md"
index 0c381001..e5b8a51c 100644
--- "a/Solutions/0235. \344\272\214\345\217\211\346\220\234\347\264\242\346\240\221\347\232\204\346\234\200\350\277\221\345\205\254\345\205\261\347\245\226\345\205\210.md"
+++ "b/Solutions/0235. \344\272\214\345\217\211\346\220\234\347\264\242\346\240\221\347\232\204\346\234\200\350\277\221\345\205\254\345\205\261\347\245\226\345\205\210.md"
@@ -22,7 +22,7 @@

-```Python
+```python
输入: root = [6,2,8,0,4,7,9,null,null,3,5], p = 2, q = 8
输出: 6
解释: 节点 2 和节点 8 的最近公共祖先是 6。
@@ -30,7 +30,7 @@
- 示例 2:
-```Python
+```python
输入: root = [6,2,8,0,4,7,9,null,null,3,5], p = 2, q = 4
输出: 2
解释: 节点 2 和节点 4 的最近公共祖先是 2, 因为根据定义最近公共祖先节点可以为节点本身。
@@ -51,7 +51,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def lowestCommonAncestor(self, root: 'TreeNode', p: 'TreeNode', q: 'TreeNode') -> 'TreeNode':
ancestor = root
diff --git "a/Solutions/0236. \344\272\214\345\217\211\346\240\221\347\232\204\346\234\200\350\277\221\345\205\254\345\205\261\347\245\226\345\205\210.md" "b/Solutions/0236. \344\272\214\345\217\211\346\240\221\347\232\204\346\234\200\350\277\221\345\205\254\345\205\261\347\245\226\345\205\210.md"
index f49adac5..6aa6e4ab 100644
--- "a/Solutions/0236. \344\272\214\345\217\211\346\240\221\347\232\204\346\234\200\350\277\221\345\205\254\345\205\261\347\245\226\345\205\210.md"
+++ "b/Solutions/0236. \344\272\214\345\217\211\346\240\221\347\232\204\346\234\200\350\277\221\345\205\254\345\205\261\347\245\226\345\205\210.md"
@@ -25,7 +25,7 @@

-```Python
+```python
输入:root = [3,5,1,6,2,0,8,null,null,7,4], p = 5, q = 1
输出:3
解释:节点 5 和节点 1 的最近公共祖先是节点 3 。
@@ -35,7 +35,7 @@

-```Python
+```python
输入:root = [3,5,1,6,2,0,8,null,null,7,4], p = 5, q = 4
输出:5
解释:节点 5 和节点 4 的最近公共祖先是节点 5 。因为根据定义最近公共祖先节点可以为节点本身。
@@ -69,7 +69,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def lowestCommonAncestor(self, root: 'TreeNode', p: 'TreeNode', q: 'TreeNode') -> 'TreeNode':
if root == p or root == q:
diff --git "a/Solutions/0237. \345\210\240\351\231\244\351\223\276\350\241\250\344\270\255\347\232\204\350\212\202\347\202\271.md" "b/Solutions/0237. \345\210\240\351\231\244\351\223\276\350\241\250\344\270\255\347\232\204\350\212\202\347\202\271.md"
index 62578981..898596fb 100644
--- "a/Solutions/0237. \345\210\240\351\231\244\351\223\276\350\241\250\344\270\255\347\232\204\350\212\202\347\202\271.md"
+++ "b/Solutions/0237. \345\210\240\351\231\244\351\223\276\350\241\250\344\270\255\347\232\204\350\212\202\347\202\271.md"
@@ -13,7 +13,7 @@
## 代码
-```Python
+```python
class Solution:
def deleteNode(self, node):
node.val = node.next.val
diff --git "a/Solutions/0238. \351\231\244\350\207\252\350\272\253\344\273\245\345\244\226\346\225\260\347\273\204\347\232\204\344\271\230\347\247\257.md" "b/Solutions/0238. \351\231\244\350\207\252\350\272\253\344\273\245\345\244\226\346\225\260\347\273\204\347\232\204\344\271\230\347\247\257.md"
index cc1841ff..6fbbb30a 100644
--- "a/Solutions/0238. \351\231\244\350\207\252\350\272\253\344\273\245\345\244\226\346\225\260\347\273\204\347\232\204\344\271\230\347\247\257.md"
+++ "b/Solutions/0238. \351\231\244\350\207\252\350\272\253\344\273\245\345\244\226\346\225\260\347\273\204\347\232\204\344\271\230\347\247\257.md"
@@ -15,7 +15,7 @@
## 代码
-```Python
+```python
class Solution:
def productExceptSelf(self, nums: List[int]) -> List[int]:
size = len(nums)
diff --git "a/Solutions/0239. \346\273\221\345\212\250\347\252\227\345\217\243\346\234\200\345\244\247\345\200\274.md" "b/Solutions/0239. \346\273\221\345\212\250\347\252\227\345\217\243\346\234\200\345\244\247\345\200\274.md"
index 41f73cf7..ee7b36b7 100644
--- "a/Solutions/0239. \346\273\221\345\212\250\347\252\227\345\217\243\346\234\200\345\244\247\345\200\274.md"
+++ "b/Solutions/0239. \346\273\221\345\212\250\347\252\227\345\217\243\346\234\200\345\244\247\345\200\274.md"
@@ -19,7 +19,7 @@
- 示例 1:
-```Python
+```python
输入:nums = [1,3,-1,-3,5,3,6,7], k = 3
输出:[3,3,5,5,6,7]
解释:
@@ -35,7 +35,7 @@
- 示例 2:
-```Python
+```python
输入:nums = [1], k = 1
输出:[1]
```
@@ -56,7 +56,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def maxSlidingWindow(self, nums: List[int], k: int) -> List[int]:
size = len(nums)
diff --git "a/Solutions/0240. \346\220\234\347\264\242\344\272\214\347\273\264\347\237\251\351\230\265 II.md" "b/Solutions/0240. \346\220\234\347\264\242\344\272\214\347\273\264\347\237\251\351\230\265 II.md"
index 3a5295ad..242afc24 100644
--- "a/Solutions/0240. \346\220\234\347\264\242\344\272\214\347\273\264\347\237\251\351\230\265 II.md"
+++ "b/Solutions/0240. \346\220\234\347\264\242\344\272\214\347\273\264\347\237\251\351\230\265 II.md"
@@ -25,7 +25,7 @@

-```Python
+```python
输入:matrix = [[1,4,7,11,15],[2,5,8,12,19],[3,6,9,16,22],[10,13,14,17,24],[18,21,23,26,30]], target = 5
输出:True
```
@@ -34,7 +34,7 @@

-```Python
+```python
输入:matrix = [[1,4,7,11,15],[2,5,8,12,19],[3,6,9,16,22],[10,13,14,17,24],[18,21,23,26,30]], target = 20
输出:False
```
@@ -53,7 +53,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def diagonalBinarySearch(self, matrix, diagonal, target):
left = 0
diff --git "a/Solutions/0241. \344\270\272\350\277\220\347\256\227\350\241\250\350\276\276\345\274\217\350\256\276\350\256\241\344\274\230\345\205\210\347\272\247.md" "b/Solutions/0241. \344\270\272\350\277\220\347\256\227\350\241\250\350\276\276\345\274\217\350\256\276\350\256\241\344\274\230\345\205\210\347\272\247.md"
index 07e1a9d2..e2ee372b 100644
--- "a/Solutions/0241. \344\270\272\350\277\220\347\256\227\350\241\250\350\276\276\345\274\217\350\256\276\350\256\241\344\274\230\345\205\210\347\272\247.md"
+++ "b/Solutions/0241. \344\270\272\350\277\220\347\256\227\350\241\250\350\276\276\345\274\217\350\256\276\350\256\241\344\274\230\345\205\210\347\272\247.md"
@@ -20,7 +20,7 @@
- 示例 1:
-```Python
+```python
输入:expression = "2-1-1"
输出:[0,2]
解释:
@@ -30,7 +30,7 @@
- 示例 2:
-```Python
+```python
输入:expression = "2*3-4*5"
输出:[-34,-14,-10,-10,10]
解释:
@@ -51,7 +51,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def diffWaysToCompute(self, expression: str) -> List[int]:
res = []
diff --git "a/Solutions/0242. \346\234\211\346\225\210\347\232\204\345\255\227\346\257\215\345\274\202\344\275\215\350\257\215.md" "b/Solutions/0242. \346\234\211\346\225\210\347\232\204\345\255\227\346\257\215\345\274\202\344\275\215\350\257\215.md"
index 46549131..3f6df973 100644
--- "a/Solutions/0242. \346\234\211\346\225\210\347\232\204\345\255\227\346\257\215\345\274\202\344\275\215\350\257\215.md"
+++ "b/Solutions/0242. \346\234\211\346\225\210\347\232\204\345\255\227\346\257\215\345\274\202\344\275\215\350\257\215.md"
@@ -16,7 +16,7 @@
## 代码
-```Python
+```python
def isAnagram(self, s: str, t: str) -> bool:
if len(s) != len(t):
return False
diff --git "a/Solutions/0249. \347\247\273\344\275\215\345\255\227\347\254\246\344\270\262\345\210\206\347\273\204.md" "b/Solutions/0249. \347\247\273\344\275\215\345\255\227\347\254\246\344\270\262\345\210\206\347\273\204.md"
index 400c7cd9..cb337c8d 100644
--- "a/Solutions/0249. \347\247\273\344\275\215\345\255\227\347\254\246\344\270\262\345\210\206\347\273\204.md"
+++ "b/Solutions/0249. \347\247\273\344\275\215\345\255\227\347\254\246\344\270\262\345\210\206\347\273\204.md"
@@ -15,7 +15,7 @@
## 代码
-```Python
+```python
import collections
class Solution:
def groupStrings(self, strings: List[str]) -> List[List[str]]:
diff --git "a/Solutions/0257. \344\272\214\345\217\211\346\240\221\347\232\204\346\211\200\346\234\211\350\267\257\345\276\204.md" "b/Solutions/0257. \344\272\214\345\217\211\346\240\221\347\232\204\346\211\200\346\234\211\350\267\257\345\276\204.md"
index 476475ca..44f8882f 100644
--- "a/Solutions/0257. \344\272\214\345\217\211\346\240\221\347\232\204\346\211\200\346\234\211\350\267\257\345\276\204.md"
+++ "b/Solutions/0257. \344\272\214\345\217\211\346\240\221\347\232\204\346\211\200\346\234\211\350\267\257\345\276\204.md"
@@ -16,7 +16,7 @@
## 代码
-```Python
+```python
class Solution:
def binaryTreePaths(self, root: TreeNode) -> List[str]:
res = []
diff --git "a/Solutions/0258. \345\220\204\344\275\215\347\233\270\345\212\240.md" "b/Solutions/0258. \345\220\204\344\275\215\347\233\270\345\212\240.md"
index 583ded17..b28c673a 100644
--- "a/Solutions/0258. \345\220\204\344\275\215\347\233\270\345\212\240.md"
+++ "b/Solutions/0258. \345\220\204\344\275\215\347\233\270\345\212\240.md"
@@ -13,7 +13,7 @@
## 代码
-```Python
+```python
class Solution:
def addDigits(self, num: int) -> int:
while num >= 10:
diff --git "a/Solutions/0259. \350\276\203\345\260\217\347\232\204\344\270\211\346\225\260\344\271\213\345\222\214.md" "b/Solutions/0259. \350\276\203\345\260\217\347\232\204\344\270\211\346\225\260\344\271\213\345\222\214.md"
index e0d55d0f..e3b53b9b 100644
--- "a/Solutions/0259. \350\276\203\345\260\217\347\232\204\344\270\211\346\225\260\344\271\213\345\222\214.md"
+++ "b/Solutions/0259. \350\276\203\345\260\217\347\232\204\344\270\211\346\225\260\344\271\213\345\222\214.md"
@@ -27,7 +27,7 @@
## 代码
-```Python
+```python
class Solution:
def threeSumSmaller(self, nums: List[int], target: int) -> int:
nums.sort()
diff --git "a/Solutions/0260. \345\217\252\345\207\272\347\216\260\344\270\200\346\254\241\347\232\204\346\225\260\345\255\227 III.md" "b/Solutions/0260. \345\217\252\345\207\272\347\216\260\344\270\200\346\254\241\347\232\204\346\225\260\345\255\227 III.md"
index 992fe240..406403bf 100644
--- "a/Solutions/0260. \345\217\252\345\207\272\347\216\260\344\270\200\346\254\241\347\232\204\346\225\260\345\255\227 III.md"
+++ "b/Solutions/0260. \345\217\252\345\207\272\347\216\260\344\270\200\346\254\241\347\232\204\346\225\260\345\255\227 III.md"
@@ -19,7 +19,7 @@
- 示例 1:
-```Python
+```python
输入:nums = [1,2,1,3,2,5]
输出:[3,5]
解释:[5, 3] 也是有效的答案。
@@ -27,7 +27,7 @@
- 示例 2:
-```Python
+```python
输入:nums = [-1,0]
输出:[-1,0]
```
@@ -53,7 +53,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def singleNumbers(self, nums: List[int]) -> List[int]:
all_xor = 0
diff --git "a/Solutions/0263. \344\270\221\346\225\260.md" "b/Solutions/0263. \344\270\221\346\225\260.md"
index 04a1e41c..c317efa9 100644
--- "a/Solutions/0263. \344\270\221\346\225\260.md"
+++ "b/Solutions/0263. \344\270\221\346\225\260.md"
@@ -18,7 +18,7 @@
## 代码
-```Python
+```python
class Solution:
def isUgly(self, n: int) -> bool:
if n <= 0:
diff --git "a/Solutions/0264. \344\270\221\346\225\260 II.md" "b/Solutions/0264. \344\270\221\346\225\260 II.md"
index 490a0d0c..8fdabb94 100644
--- "a/Solutions/0264. \344\270\221\346\225\260 II.md"
+++ "b/Solutions/0264. \344\270\221\346\225\260 II.md"
@@ -21,7 +21,7 @@
## 代码
-```Python
+```python
class Solution:
def nthUglyNumber(self, n: int) -> int:
dp = [1 for _ in range(n)]
diff --git "a/Solutions/0268. \344\270\242\345\244\261\347\232\204\346\225\260\345\255\227.md" "b/Solutions/0268. \344\270\242\345\244\261\347\232\204\346\225\260\345\255\227.md"
index 23cf8734..025a7970 100644
--- "a/Solutions/0268. \344\270\242\345\244\261\347\232\204\346\225\260\345\255\227.md"
+++ "b/Solutions/0268. \344\270\242\345\244\261\347\232\204\346\225\260\345\255\227.md"
@@ -34,7 +34,7 @@
## 代码
1. 哈希表
-```Python
+```python
class Solution:
def missingNumber(self, nums: List[int]) -> int:
numSet = set(nums)
@@ -45,7 +45,7 @@ class Solution:
```
2. 数学计算
-```Python
+```python
class Solution:
def missingNumber(self, nums: List[int]) -> int:
sum_nums = sum(nums)
diff --git "a/Solutions/0270. \346\234\200\346\216\245\350\277\221\347\232\204\344\272\214\345\217\211\346\220\234\347\264\242\346\240\221\345\200\274.md" "b/Solutions/0270. \346\234\200\346\216\245\350\277\221\347\232\204\344\272\214\345\217\211\346\220\234\347\264\242\346\240\221\345\200\274.md"
index 8a2c1b96..8544d829 100644
--- "a/Solutions/0270. \346\234\200\346\216\245\350\277\221\347\232\204\344\272\214\345\217\211\346\220\234\347\264\242\346\240\221\345\200\274.md"
+++ "b/Solutions/0270. \346\234\200\346\216\245\350\277\221\347\232\204\344\272\214\345\217\211\346\220\234\347\264\242\346\240\221\345\200\274.md"
@@ -20,7 +20,7 @@
## 代码
-```Python
+```python
class Solution:
def closestValue(self, root: TreeNode, target: float) -> int:
closest = root.val
diff --git "a/Solutions/0278. \347\254\254\344\270\200\344\270\252\351\224\231\350\257\257\347\232\204\347\211\210\346\234\254.md" "b/Solutions/0278. \347\254\254\344\270\200\344\270\252\351\224\231\350\257\257\347\232\204\347\211\210\346\234\254.md"
index dd2d826b..b9d22bd0 100644
--- "a/Solutions/0278. \347\254\254\344\270\200\344\270\252\351\224\231\350\257\257\347\232\204\347\211\210\346\234\254.md"
+++ "b/Solutions/0278. \347\254\254\344\270\200\344\270\252\351\224\231\350\257\257\347\232\204\347\211\210\346\234\254.md"
@@ -18,7 +18,7 @@
- 示例 1:
-```Python
+```python
输入:n = 5, bad = 4
输出:4
解释:
@@ -30,7 +30,7 @@
- 示例 2:
-```Python
+```python
输入:n = 1, bad = 1
输出:1
```
@@ -45,7 +45,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def firstBadVersion(self, n):
left = 1
diff --git "a/Solutions/0279. \345\256\214\345\205\250\345\271\263\346\226\271\346\225\260.md" "b/Solutions/0279. \345\256\214\345\205\250\345\271\263\346\226\271\346\225\260.md"
index 3d8f8393..5e0e03bc 100644
--- "a/Solutions/0279. \345\256\214\345\205\250\345\271\263\346\226\271\346\225\260.md"
+++ "b/Solutions/0279. \345\256\214\345\205\250\345\271\263\346\226\271\346\225\260.md"
@@ -17,7 +17,7 @@
- 示例 1:
-```Python
+```python
输入:n = 12
输出:3
解释:12 = 4 + 4 + 4
@@ -25,7 +25,7 @@
- 示例 2:
-```Python
+```python
输入:n = 13
输出:2
解释:13 = 4 + 9
@@ -64,7 +64,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def numSquares(self, n: int) -> int:
if n == 0:
@@ -131,7 +131,7 @@ $dp[w] = min \lbrace dp[w], dp[w - num] + 1$
### 思路 2:代码
-```Python
+```python
class Solution:
def numSquares(self, n: int) -> int:
dp = [n + 1 for _ in range(n + 1)]
diff --git "a/Solutions/0283. \347\247\273\345\212\250\351\233\266.md" "b/Solutions/0283. \347\247\273\345\212\250\351\233\266.md"
index 73d66214..8269f25b 100644
--- "a/Solutions/0283. \347\247\273\345\212\250\351\233\266.md"
+++ "b/Solutions/0283. \347\247\273\345\212\250\351\233\266.md"
@@ -19,14 +19,14 @@
- 示例 1:
-```Python
+```python
输入: nums = [0,1,0,3,12]
输出: [1,3,12,0,0]
```
- 示例 2:
-```Python
+```python
输入: nums = [0]
输出: [0]
```
@@ -43,7 +43,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def moveZeroes(self, nums: List[int]) -> None:
for i in range(len(nums)):
@@ -67,7 +67,7 @@ class Solution:
### 思路 2:代码
-```Python
+```python
class Solution:
def moveZeroes(self, nums: List[int]) -> None:
slow = 0
diff --git "a/Solutions/0285. \344\272\214\345\217\211\346\220\234\347\264\242\346\240\221\344\270\255\347\232\204\344\270\255\345\272\217\345\220\216\347\273\247.md" "b/Solutions/0285. \344\272\214\345\217\211\346\220\234\347\264\242\346\240\221\344\270\255\347\232\204\344\270\255\345\272\217\345\220\216\347\273\247.md"
index 69997aab..4fbd7cbc 100644
--- "a/Solutions/0285. \344\272\214\345\217\211\346\220\234\347\264\242\346\240\221\344\270\255\347\232\204\344\270\255\345\272\217\345\220\216\347\273\247.md"
+++ "b/Solutions/0285. \344\272\214\345\217\211\346\220\234\347\264\242\346\240\221\344\270\255\347\232\204\344\270\255\345\272\217\345\220\216\347\273\247.md"
@@ -24,7 +24,7 @@
## 代码
-```Python
+```python
class Solution:
def inOrder(self, root, res):
if not root:
diff --git "a/Solutions/0286. \345\242\231\344\270\216\351\227\250.md" "b/Solutions/0286. \345\242\231\344\270\216\351\227\250.md"
index fcc38bfa..dec1371d 100644
--- "a/Solutions/0286. \345\242\231\344\270\216\351\227\250.md"
+++ "b/Solutions/0286. \345\242\231\344\270\216\351\227\250.md"
@@ -19,7 +19,7 @@
## 代码
-```Python
+```python
class Solution:
def wallsAndGates(self, rooms: List[List[int]]) -> None:
"""
diff --git "a/Solutions/0287. \345\257\273\346\211\276\351\207\215\345\244\215\346\225\260.md" "b/Solutions/0287. \345\257\273\346\211\276\351\207\215\345\244\215\346\225\260.md"
index 36a37085..55ec8695 100644
--- "a/Solutions/0287. \345\257\273\346\211\276\351\207\215\345\244\215\346\225\260.md"
+++ "b/Solutions/0287. \345\257\273\346\211\276\351\207\215\345\244\215\346\225\260.md"
@@ -15,7 +15,7 @@
## 代码
-```Python
+```python
class Solution:
def findDuplicate(self, nums: List[int]) -> int:
n = len(nums)
diff --git "a/Solutions/0288. \345\215\225\350\257\215\347\232\204\345\224\257\344\270\200\347\274\251\345\206\231.md" "b/Solutions/0288. \345\215\225\350\257\215\347\232\204\345\224\257\344\270\200\347\274\251\345\206\231.md"
index 780f8147..eebaafd7 100644
--- "a/Solutions/0288. \345\215\225\350\257\215\347\232\204\345\224\257\344\270\200\347\274\251\345\206\231.md"
+++ "b/Solutions/0288. \345\215\225\350\257\215\347\232\204\345\224\257\344\270\200\347\274\251\345\206\231.md"
@@ -36,7 +36,7 @@
## 代码
-```Python
+```python
def isUnique(self, word: str) -> bool:
if len(word) <= 2:
abbr = word
diff --git "a/Solutions/0289. \347\224\237\345\221\275\346\270\270\346\210\217.md" "b/Solutions/0289. \347\224\237\345\221\275\346\270\270\346\210\217.md"
index fe971a84..11e944b5 100644
--- "a/Solutions/0289. \347\224\237\345\221\275\346\270\270\346\210\217.md"
+++ "b/Solutions/0289. \347\224\237\345\221\275\346\270\270\346\210\217.md"
@@ -35,7 +35,7 @@

-```Python
+```python
输入:board = [[0,1,0],[0,0,1],[1,1,1],[0,0,0]]
输出:[[0,0,0],[1,0,1],[0,1,1],[0,1,0]]
```
@@ -44,7 +44,7 @@

-```Python
+```python
输入:board = [[1,1],[1,0]]
输出:[[1,1],[1,1]]
```
@@ -69,7 +69,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def gameOfLife(self, board: List[List[int]]) -> None:
"""
diff --git "a/Solutions/0290. \345\215\225\350\257\215\350\247\204\345\276\213.md" "b/Solutions/0290. \345\215\225\350\257\215\350\247\204\345\276\213.md"
index ab537048..fcedd8d8 100644
--- "a/Solutions/0290. \345\215\225\350\257\215\350\247\204\345\276\213.md"
+++ "b/Solutions/0290. \345\215\225\350\257\215\350\247\204\345\276\213.md"
@@ -25,7 +25,7 @@
## 代码
-```Python
+```python
class Solution:
def wordPattern(self, pattern: str, s: str) -> bool:
pattern_dict = dict()
diff --git "a/Solutions/0292. Nim \346\270\270\346\210\217.md" "b/Solutions/0292. Nim \346\270\270\346\210\217.md"
index d1dbcd3c..3bddf16b 100644
--- "a/Solutions/0292. Nim \346\270\270\346\210\217.md"
+++ "b/Solutions/0292. Nim \346\270\270\346\210\217.md"
@@ -29,7 +29,7 @@
## 代码
-```Python
+```python
class Solution:
def canWinNim(self, n: int) -> bool:
return n % 4 != 0
diff --git "a/Solutions/0295. \346\225\260\346\215\256\346\265\201\347\232\204\344\270\255\344\275\215\346\225\260.md" "b/Solutions/0295. \346\225\260\346\215\256\346\265\201\347\232\204\344\270\255\344\275\215\346\225\260.md"
index bf8204c4..455492c3 100644
--- "a/Solutions/0295. \346\225\260\346\215\256\346\265\201\347\232\204\344\270\255\344\275\215\346\225\260.md"
+++ "b/Solutions/0295. \346\225\260\346\215\256\346\265\201\347\232\204\344\270\255\344\275\215\346\225\260.md"
@@ -24,7 +24,7 @@
## 代码
-```Python
+```python
import heapq
class MedianFinder:
diff --git "a/Solutions/0297. \344\272\214\345\217\211\346\240\221\347\232\204\345\272\217\345\210\227\345\214\226\344\270\216\345\217\215\345\272\217\345\210\227\345\214\226.md" "b/Solutions/0297. \344\272\214\345\217\211\346\240\221\347\232\204\345\272\217\345\210\227\345\214\226\344\270\216\345\217\215\345\272\217\345\210\227\345\214\226.md"
index 55032bbe..093c0dc2 100644
--- "a/Solutions/0297. \344\272\214\345\217\211\346\240\221\347\232\204\345\272\217\345\210\227\345\214\226\344\270\216\345\217\215\345\272\217\345\210\227\345\214\226.md"
+++ "b/Solutions/0297. \344\272\214\345\217\211\346\240\221\347\232\204\345\272\217\345\210\227\345\214\226\344\270\216\345\217\215\345\272\217\345\210\227\345\214\226.md"
@@ -19,14 +19,14 @@

-```Python
+```python
输入:root = [1,2,3,null,null,4,5]
输出:[1,2,3,null,null,4,5]
```
- 示例 2:
-```Python
+```python
输入:root = [1,2]
输出:[1,2]
```
@@ -51,7 +51,7 @@
### 思路 1:代码
-```Python
+```python
class Codec:
def serialize(self, root):
diff --git "a/Solutions/0300. \346\234\200\351\225\277\351\200\222\345\242\236\345\255\220\345\272\217\345\210\227.md" "b/Solutions/0300. \346\234\200\351\225\277\351\200\222\345\242\236\345\255\220\345\272\217\345\210\227.md"
index 5bf1b560..93264f19 100644
--- "a/Solutions/0300. \346\234\200\351\225\277\351\200\222\345\242\236\345\255\220\345\272\217\345\210\227.md"
+++ "b/Solutions/0300. \346\234\200\351\225\277\351\200\222\345\242\236\345\255\220\345\272\217\345\210\227.md"
@@ -19,7 +19,7 @@
- 示例 1:
-```Python
+```python
输入:nums = [10,9,2,5,3,7,101,18]
输出:4
解释:最长递增子序列是 [2,3,7,101],因此长度为 4。
@@ -27,7 +27,7 @@
- 示例 2:
-```Python
+```python
输入:nums = [0,1,0,3,2,3]
输出:4
```
@@ -66,7 +66,7 @@
### 思路 1:动态规划代码
-```Python
+```python
class Solution:
def lengthOfLIS(self, nums: List[int]) -> int:
size = len(nums)
diff --git "a/Solutions/0303. \345\214\272\345\237\237\345\222\214\346\243\200\347\264\242 - \346\225\260\347\273\204\344\270\215\345\217\257\345\217\230.md" "b/Solutions/0303. \345\214\272\345\237\237\345\222\214\346\243\200\347\264\242 - \346\225\260\347\273\204\344\270\215\345\217\257\345\217\230.md"
index 51e26214..d43f61ac 100644
--- "a/Solutions/0303. \345\214\272\345\237\237\345\222\214\346\243\200\347\264\242 - \346\225\260\347\273\204\344\270\215\345\217\257\345\217\230.md"
+++ "b/Solutions/0303. \345\214\272\345\237\237\345\222\214\346\243\200\347\264\242 - \346\225\260\347\273\204\344\270\215\345\217\257\345\217\230.md"
@@ -25,7 +25,7 @@
- 示例 1:
-```Python
+```python
给定 nums = [-2, 0, 3, -5, 2, -1]
求和 sumRange(0, 2) -> 1
@@ -43,7 +43,7 @@
### 思路 1 线段树代码:
-```Python
+```python
# 线段树的节点类
class SegTreeNode:
def __init__(self, val=0):
diff --git "a/Solutions/0304. \344\272\214\347\273\264\345\214\272\345\237\237\345\222\214\346\243\200\347\264\242 - \347\237\251\351\230\265\344\270\215\345\217\257\345\217\230.md" "b/Solutions/0304. \344\272\214\347\273\264\345\214\272\345\237\237\345\222\214\346\243\200\347\264\242 - \347\237\251\351\230\265\344\270\215\345\217\257\345\217\230.md"
index 37a2689a..b6cafff1 100644
--- "a/Solutions/0304. \344\272\214\347\273\264\345\214\272\345\237\237\345\222\214\346\243\200\347\264\242 - \347\237\251\351\230\265\344\270\215\345\217\257\345\217\230.md"
+++ "b/Solutions/0304. \344\272\214\347\273\264\345\214\272\345\237\237\345\222\214\346\243\200\347\264\242 - \347\237\251\351\230\265\344\270\215\345\217\257\345\217\230.md"
@@ -22,7 +22,7 @@
## 代码
-```Python
+```python
class NumMatrix:
def __init__(self, matrix: List[List[int]]):
diff --git "a/Solutions/0307. \345\214\272\345\237\237\345\222\214\346\243\200\347\264\242 - \346\225\260\347\273\204\345\217\257\344\277\256\346\224\271.md" "b/Solutions/0307. \345\214\272\345\237\237\345\222\214\346\243\200\347\264\242 - \346\225\260\347\273\204\345\217\257\344\277\256\346\224\271.md"
index 5685b062..eb5d48d0 100644
--- "a/Solutions/0307. \345\214\272\345\237\237\345\222\214\346\243\200\347\264\242 - \346\225\260\347\273\204\345\217\257\344\277\256\346\224\271.md"
+++ "b/Solutions/0307. \345\214\272\345\237\237\345\222\214\346\243\200\347\264\242 - \346\225\260\347\273\204\345\217\257\344\277\256\346\224\271.md"
@@ -47,7 +47,7 @@
### 思路 1 线段树代码:
-```Python
+```python
# 线段树的节点类
class SegTreeNode:
def __init__(self, val=0):
diff --git "a/Solutions/0309. \346\234\200\344\275\263\344\271\260\345\215\226\350\202\241\347\245\250\346\227\266\346\234\272\345\220\253\345\206\267\345\206\273\346\234\237.md" "b/Solutions/0309. \346\234\200\344\275\263\344\271\260\345\215\226\350\202\241\347\245\250\346\227\266\346\234\272\345\220\253\345\206\267\345\206\273\346\234\237.md"
index ba0ed460..a456d46e 100644
--- "a/Solutions/0309. \346\234\200\344\275\263\344\271\260\345\215\226\350\202\241\347\245\250\346\227\266\346\234\272\345\220\253\345\206\267\345\206\273\346\234\237.md"
+++ "b/Solutions/0309. \346\234\200\344\275\263\344\271\260\345\215\226\350\202\241\347\245\250\346\227\266\346\234\272\345\220\253\345\206\267\345\206\273\346\234\237.md"
@@ -63,7 +63,7 @@
## 代码
-```Python
+```python
class Solution:
def maxProfit(self, prices: List[int]) -> int:
size = len(prices)
diff --git "a/Solutions/0310. \346\234\200\345\260\217\351\253\230\345\272\246\346\240\221.md" "b/Solutions/0310. \346\234\200\345\260\217\351\253\230\345\272\246\346\240\221.md"
index 65112a60..cec4fa52 100644
--- "a/Solutions/0310. \346\234\200\345\260\217\351\253\230\345\272\246\346\240\221.md"
+++ "b/Solutions/0310. \346\234\200\345\260\217\351\253\230\345\272\246\346\240\221.md"
@@ -27,7 +27,7 @@

-```Python
+```python
输入:n = 4, edges = [[1,0],[1,2],[1,3]]
输出:[1]
解释:如图所示,当根是标签为 1 的节点时,树的高度是 1 ,这是唯一的最小高度树。
@@ -37,7 +37,7 @@

-```Python
+```python
输入:n = 6, edges = [[3,0],[3,1],[3,2],[3,4],[5,4]]
输出:[3,4]
```
@@ -78,7 +78,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def findMinHeightTrees(self, n: int, edges: List[List[int]]) -> List[int]:
graph = [[] for _ in range(n)]
diff --git "a/Solutions/0312. \346\210\263\346\260\224\347\220\203.md" "b/Solutions/0312. \346\210\263\346\260\224\347\220\203.md"
index d132c3cc..a7b86ca9 100644
--- "a/Solutions/0312. \346\210\263\346\260\224\347\220\203.md"
+++ "b/Solutions/0312. \346\210\263\346\260\224\347\220\203.md"
@@ -19,7 +19,7 @@
- 示例 1:
-```Python
+```python
输入:nums = [3,1,5,8]
输出:167
解释:
@@ -29,7 +29,7 @@ coins = 3*1*5 + 3*5*8 + 1*3*8 + 1*8*1 = 167
- 示例 2:
-```Python
+```python
输入:nums = [1,5]
输出:10
解释:
@@ -71,7 +71,7 @@ $dp[i][j] = max \lbrace dp[i][k] + dp[k][j] + nums[i] \times nums[k] \times nums
### 思路 1:代码
-```Python
+```python
class Solution:
def maxCoins(self, nums: List[int]) -> int:
size = len(nums)
diff --git "a/Solutions/0315. \350\256\241\347\256\227\345\217\263\344\276\247\345\260\217\344\272\216\345\275\223\345\211\215\345\205\203\347\264\240\347\232\204\344\270\252\346\225\260.md" "b/Solutions/0315. \350\256\241\347\256\227\345\217\263\344\276\247\345\260\217\344\272\216\345\275\223\345\211\215\345\205\203\347\264\240\347\232\204\344\270\252\346\225\260.md"
index 09636d88..4f7514b4 100644
--- "a/Solutions/0315. \350\256\241\347\256\227\345\217\263\344\276\247\345\260\217\344\272\216\345\275\223\345\211\215\345\205\203\347\264\240\347\232\204\344\270\252\346\225\260.md"
+++ "b/Solutions/0315. \350\256\241\347\256\227\345\217\263\344\276\247\345\260\217\344\272\216\345\275\223\345\211\215\345\205\203\347\264\240\347\232\204\344\270\252\346\225\260.md"
@@ -22,7 +22,7 @@
## 代码
-```Python
+```python
import bisect
class BinaryIndexTree:
diff --git "a/Solutions/0316. \345\216\273\351\231\244\351\207\215\345\244\215\345\255\227\346\257\215.md" "b/Solutions/0316. \345\216\273\351\231\244\351\207\215\345\244\215\345\255\227\346\257\215.md"
index 25adace3..cafa083f 100644
--- "a/Solutions/0316. \345\216\273\351\231\244\351\207\215\345\244\215\345\255\227\346\257\215.md"
+++ "b/Solutions/0316. \345\216\273\351\231\244\351\207\215\345\244\215\345\255\227\346\257\215.md"
@@ -18,14 +18,14 @@
- 示例 1:
-```Python
+```python
输入:s = "bcabc"
输出:"abc"
```
- 示例 2:
-```Python
+```python
输入:s = "cbacdcbc"
输出:"acdb"
```
@@ -55,7 +55,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def removeDuplicateLetters(self, s: str) -> str:
stack = []
diff --git "a/Solutions/0318. \346\234\200\345\244\247\345\215\225\350\257\215\351\225\277\345\272\246\344\271\230\347\247\257.md" "b/Solutions/0318. \346\234\200\345\244\247\345\215\225\350\257\215\351\225\277\345\272\246\344\271\230\347\247\257.md"
index 5afbc0c7..24dba754 100644
--- "a/Solutions/0318. \346\234\200\345\244\247\345\215\225\350\257\215\351\225\277\345\272\246\344\271\230\347\247\257.md"
+++ "b/Solutions/0318. \346\234\200\345\244\247\345\215\225\350\257\215\351\225\277\345\272\246\344\271\230\347\247\257.md"
@@ -19,7 +19,7 @@
## 代码
-```Python
+```python
class Solution:
def maxProduct(self, words: List[str]) -> int:
size = len(words)
diff --git "a/Solutions/0322. \351\233\266\351\222\261\345\205\221\346\215\242.md" "b/Solutions/0322. \351\233\266\351\222\261\345\205\221\346\215\242.md"
index 25ffe2c2..80d60b4e 100644
--- "a/Solutions/0322. \351\233\266\351\222\261\345\205\221\346\215\242.md"
+++ "b/Solutions/0322. \351\233\266\351\222\261\345\205\221\346\215\242.md"
@@ -19,7 +19,7 @@
- 示例 1:
-```Python
+```python
输入:coins = [1, 2, 5], amount = 11
输出:3
解释:11 = 5 + 5 + 1
@@ -27,7 +27,7 @@
- 示例 2:
-```Python
+```python
输入:coins = [2], amount = 3
输出:-1
```
@@ -49,7 +49,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def coinChange(self, coins: List[int], amount: int) -> int:
if amount == 0:
@@ -118,7 +118,7 @@ $dp[c] = \begin{cases} dp[c] & c < coins[i - 1] \cr min \lbrace dp[c], dp[c - co
### 思路 2:代码
-```Python
+```python
class Solution:
def coinChange(self, coins: List[int], amount: int) -> int:
size = len(coins)
diff --git "a/Solutions/0323. \346\227\240\345\220\221\345\233\276\344\270\255\350\277\236\351\200\232\345\210\206\351\207\217\347\232\204\346\225\260\347\233\256.md" "b/Solutions/0323. \346\227\240\345\220\221\345\233\276\344\270\255\350\277\236\351\200\232\345\210\206\351\207\217\347\232\204\346\225\260\347\233\256.md"
index 5172d9de..342b738c 100644
--- "a/Solutions/0323. \346\227\240\345\220\221\345\233\276\344\270\255\350\277\236\351\200\232\345\210\206\351\207\217\347\232\204\346\225\260\347\233\256.md"
+++ "b/Solutions/0323. \346\227\240\345\220\221\345\233\276\344\270\255\350\277\236\351\200\232\345\210\206\351\207\217\347\232\204\346\225\260\347\233\256.md"
@@ -22,7 +22,7 @@
- 示例 1:
-```Python
+```python
输入: n = 5 和 edges = [[0, 1], [1, 2], [3, 4]]
0 3
| |
@@ -32,7 +32,7 @@
- 示例 2:
-```Python
+```python
输入: n = 5 和 edges = [[0, 1], [1, 2], [2, 3], [3, 4]]
0 4
| |
@@ -60,7 +60,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def dfs(self, visited, i, graph):
visited[i] = True
@@ -103,7 +103,7 @@ class Solution:
### 思路 2:代码
-```Python
+```python
import collections
class Solution:
diff --git "a/Solutions/0324. \346\221\206\345\212\250\346\216\222\345\272\217 II.md" "b/Solutions/0324. \346\221\206\345\212\250\346\216\222\345\272\217 II.md"
index 34462dcc..b5bb2faf 100644
--- "a/Solutions/0324. \346\221\206\345\212\250\346\216\222\345\272\217 II.md"
+++ "b/Solutions/0324. \346\221\206\345\212\250\346\216\222\345\272\217 II.md"
@@ -20,7 +20,7 @@
## 代码
-```Python
+```python
class Solution:
def wiggleSort(self, nums: List[int]) -> None:
"""
diff --git "a/Solutions/0326. 3 \347\232\204\345\271\202.md" "b/Solutions/0326. 3 \347\232\204\345\271\202.md"
index c29b35dd..cdcbbf5c 100644
--- "a/Solutions/0326. 3 \347\232\204\345\271\202.md"
+++ "b/Solutions/0326. 3 \347\232\204\345\271\202.md"
@@ -17,7 +17,7 @@
## 代码
-```Python
+```python
class Solution:
def isPowerOfThree(self, n: int) -> bool:
if n <= 0:
diff --git "a/Solutions/0328. \345\245\207\345\201\266\351\223\276\350\241\250.md" "b/Solutions/0328. \345\245\207\345\201\266\351\223\276\350\241\250.md"
index 9eafa87d..75038a56 100644
--- "a/Solutions/0328. \345\245\207\345\201\266\351\223\276\350\241\250.md"
+++ "b/Solutions/0328. \345\245\207\345\201\266\351\223\276\350\241\250.md"
@@ -22,7 +22,7 @@

-```Python
+```python
输入: head = [1,2,3,4,5]
输出: [1,3,5,2,4]
```
@@ -31,7 +31,7 @@

-```Python
+```python
输入: head = [2,1,3,5,6,4,7]
输出: [2,3,6,7,1,5,4]
```
@@ -46,7 +46,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def oddEvenList(self, head: ListNode) -> ListNode:
if not head or not head.next or not head.next.next:
diff --git "a/Solutions/0329. \347\237\251\351\230\265\344\270\255\347\232\204\346\234\200\351\225\277\351\200\222\345\242\236\350\267\257\345\276\204.md" "b/Solutions/0329. \347\237\251\351\230\265\344\270\255\347\232\204\346\234\200\351\225\277\351\200\222\345\242\236\350\267\257\345\276\204.md"
index ea493ea5..1378031f 100644
--- "a/Solutions/0329. \347\237\251\351\230\265\344\270\255\347\232\204\346\234\200\351\225\277\351\200\222\345\242\236\350\267\257\345\276\204.md"
+++ "b/Solutions/0329. \347\237\251\351\230\265\344\270\255\347\232\204\346\234\200\351\225\277\351\200\222\345\242\236\350\267\257\345\276\204.md"
@@ -15,7 +15,7 @@
## 代码
-```Python
+```python
class Solution:
max_len = 0
directions = {(1, 0), (-1, 0), (0, 1), (0, -1)}
diff --git "a/Solutions/0334. \351\200\222\345\242\236\347\232\204\344\270\211\345\205\203\345\255\220\345\272\217\345\210\227.md" "b/Solutions/0334. \351\200\222\345\242\236\347\232\204\344\270\211\345\205\203\345\255\220\345\272\217\345\210\227.md"
index 792dfcbf..d75be091 100644
--- "a/Solutions/0334. \351\200\222\345\242\236\347\232\204\344\270\211\345\205\203\345\255\220\345\272\217\345\210\227.md"
+++ "b/Solutions/0334. \351\200\222\345\242\236\347\232\204\344\270\211\345\205\203\345\255\220\345\272\217\345\210\227.md"
@@ -35,7 +35,7 @@
## 代码
-```Python
+```python
class Solution:
def increasingTriplet(self, nums: List[int]) -> bool:
a = float('inf')
diff --git "a/Solutions/0336. \345\233\236\346\226\207\345\257\271.md" "b/Solutions/0336. \345\233\236\346\226\207\345\257\271.md"
index 214de461..eb013220 100644
--- "a/Solutions/0336. \345\233\236\346\226\207\345\257\271.md"
+++ "b/Solutions/0336. \345\233\236\346\226\207\345\257\271.md"
@@ -27,7 +27,7 @@
## 代码
-```Python
+```python
class Trie:
def __init__(self):
diff --git "a/Solutions/0337. \346\211\223\345\256\266\345\212\253\350\210\215 III.md" "b/Solutions/0337. \346\211\223\345\256\266\345\212\253\350\210\215 III.md"
index e4e0309a..bbf241e6 100644
--- "a/Solutions/0337. \346\211\223\345\256\266\345\212\253\350\210\215 III.md"
+++ "b/Solutions/0337. \346\211\223\345\256\266\345\212\253\350\210\215 III.md"
@@ -37,7 +37,7 @@
## 代码
-```Python
+```python
class Solution:
def dfs(self, root: TreeNode):
if not root:
diff --git "a/Solutions/0338. \346\257\224\347\211\271\344\275\215\350\256\241\346\225\260.md" "b/Solutions/0338. \346\257\224\347\211\271\344\275\215\350\256\241\346\225\260.md"
index 2022a074..4121425e 100644
--- "a/Solutions/0338. \346\257\224\347\211\271\344\275\215\350\256\241\346\225\260.md"
+++ "b/Solutions/0338. \346\257\224\347\211\271\344\275\215\350\256\241\346\225\260.md"
@@ -19,7 +19,7 @@
- 示例 1:
-```Python
+```python
输入:n = 5
输出:[0,1,1,2,1,2]
解释:
@@ -67,7 +67,7 @@
### 思路 1:动态规划代码
-```Python
+```python
class Solution:
def countBits(self, n: int) -> List[int]:
dp = [0 for _ in range(n + 1)]
diff --git "a/Solutions/0340. \350\207\263\345\244\232\345\214\205\345\220\253 K \344\270\252\344\270\215\345\220\214\345\255\227\347\254\246\347\232\204\346\234\200\351\225\277\345\255\220\344\270\262.md" "b/Solutions/0340. \350\207\263\345\244\232\345\214\205\345\220\253 K \344\270\252\344\270\215\345\220\214\345\255\227\347\254\246\347\232\204\346\234\200\351\225\277\345\255\220\344\270\262.md"
index f7f2fe72..030f5488 100644
--- "a/Solutions/0340. \350\207\263\345\244\232\345\214\205\345\220\253 K \344\270\252\344\270\215\345\220\214\345\255\227\347\254\246\347\232\204\346\234\200\351\225\277\345\255\220\344\270\262.md"
+++ "b/Solutions/0340. \350\207\263\345\244\232\345\214\205\345\220\253 K \344\270\252\344\270\215\345\220\214\345\255\227\347\254\246\347\232\204\346\234\200\351\225\277\345\255\220\344\270\262.md"
@@ -23,7 +23,7 @@
## 代码
-```Python
+```python
class Solution:
def lengthOfLongestSubstringKDistinct(self, s: str, k: int) -> int:
ans = 0
diff --git "a/Solutions/0341. \346\211\201\345\271\263\345\214\226\345\265\214\345\245\227\345\210\227\350\241\250\350\277\255\344\273\243\345\231\250.md" "b/Solutions/0341. \346\211\201\345\271\263\345\214\226\345\265\214\345\245\227\345\210\227\350\241\250\350\277\255\344\273\243\345\231\250.md"
index b9306967..443c7e11 100644
--- "a/Solutions/0341. \346\211\201\345\271\263\345\214\226\345\265\214\345\245\227\345\210\227\350\241\250\350\277\255\344\273\243\345\231\250.md"
+++ "b/Solutions/0341. \346\211\201\345\271\263\345\214\226\345\265\214\345\245\227\345\210\227\350\241\250\350\277\255\344\273\243\345\231\250.md"
@@ -27,7 +27,7 @@ NestedInteger 类提供了三个方法:
## 代码
-```Python
+```python
class NestedIterator:
def __init__(self, nestedList: [NestedInteger]):
self.stack = []
diff --git "a/Solutions/0342. 4\347\232\204\345\271\202.md" "b/Solutions/0342. 4\347\232\204\345\271\202.md"
index c8a99819..81461fd9 100644
--- "a/Solutions/0342. 4\347\232\204\345\271\202.md"
+++ "b/Solutions/0342. 4\347\232\204\345\271\202.md"
@@ -24,7 +24,7 @@ n 如果是 4 的幂次方,那么 n 肯定是 2 的幂次方,2 的幂次方
## 代码
-```Python
+```python
class Solution:
def isPowerOfFour(self, n: int) -> bool:
return n > 0 and (n & (n-1)) == 0 and (n-1) % 3 == 0
diff --git "a/Solutions/0343. \346\225\264\346\225\260\346\213\206\345\210\206.md" "b/Solutions/0343. \346\225\264\346\225\260\346\213\206\345\210\206.md"
index 8c720b1c..30413ed6 100644
--- "a/Solutions/0343. \346\225\264\346\225\260\346\213\206\345\210\206.md"
+++ "b/Solutions/0343. \346\225\264\346\225\260\346\213\206\345\210\206.md"
@@ -17,7 +17,7 @@
- 示例 1:
-```Python
+```python
输入: n = 2
输出: 1
解释: 2 = 1 + 1, 1 × 1 = 1。
@@ -25,7 +25,7 @@
- 示例 2:
-```Python
+```python
输入: n = 10
输出: 36
解释: 10 = 3 + 3 + 4, 3 × 3 × 4 = 36。
@@ -66,7 +66,7 @@ $dp[i] = max_{1 \le j < i}\lbrace max(j \times (i - j), j \times dp[i - j]) \rbr
### 思路 1:代码
-```Python
+```python
class Solution:
def integerBreak(self, n: int) -> int:
dp = [0 for _ in range(n + 1)]
diff --git "a/Solutions/0344. \345\217\215\350\275\254\345\255\227\347\254\246\344\270\262.md" "b/Solutions/0344. \345\217\215\350\275\254\345\255\227\347\254\246\344\270\262.md"
index 33e815b7..492f1249 100644
--- "a/Solutions/0344. \345\217\215\350\275\254\345\255\227\347\254\246\344\270\262.md"
+++ "b/Solutions/0344. \345\217\215\350\275\254\345\255\227\347\254\246\344\270\262.md"
@@ -19,14 +19,14 @@
- 示例 1:
-```Python
+```python
输入:s = ["h","e","l","l","o"]
输出:["o","l","l","e","h"]
```
- 示例 2:
-```Python
+```python
输入:s = ["H","a","n","n","a","h"]
输出:["h","a","n","n","a","H"]
```
@@ -41,7 +41,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def reverseString(self, s: List[str]) -> None:
left, right = 0, len(s) - 1
diff --git "a/Solutions/0345. \345\217\215\350\275\254\345\255\227\347\254\246\344\270\262\344\270\255\347\232\204\345\205\203\351\237\263\345\255\227\346\257\215.md" "b/Solutions/0345. \345\217\215\350\275\254\345\255\227\347\254\246\344\270\262\344\270\255\347\232\204\345\205\203\351\237\263\345\255\227\346\257\215.md"
index 9fbcaab5..042e7039 100644
--- "a/Solutions/0345. \345\217\215\350\275\254\345\255\227\347\254\246\344\270\262\344\270\255\347\232\204\345\205\203\351\237\263\345\255\227\346\257\215.md"
+++ "b/Solutions/0345. \345\217\215\350\275\254\345\255\227\347\254\246\344\270\262\344\270\255\347\232\204\345\205\203\351\237\263\345\255\227\346\257\215.md"
@@ -14,7 +14,7 @@
## 代码
-```Python
+```python
class Solution:
def reverseVowels(self, s: str) -> str:
vowels = ['a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U']
diff --git "a/Solutions/0346. \346\225\260\346\215\256\346\265\201\344\270\255\347\232\204\347\247\273\345\212\250\345\271\263\345\235\207\345\200\274.md" "b/Solutions/0346. \346\225\260\346\215\256\346\265\201\344\270\255\347\232\204\347\247\273\345\212\250\345\271\263\345\235\207\345\200\274.md"
index b713f233..fafbe81f 100644
--- "a/Solutions/0346. \346\225\260\346\215\256\346\265\201\344\270\255\347\232\204\347\247\273\345\212\250\345\271\263\345\235\207\345\200\274.md"
+++ "b/Solutions/0346. \346\225\260\346\215\256\346\265\201\344\270\255\347\232\204\347\247\273\345\212\250\345\271\263\345\235\207\345\200\274.md"
@@ -24,7 +24,7 @@
## 代码
-```Python
+```python
class MovingAverage:
def __init__(self, size: int):
diff --git "a/Solutions/0347. \345\211\215 K \344\270\252\351\253\230\351\242\221\345\205\203\347\264\240.md" "b/Solutions/0347. \345\211\215 K \344\270\252\351\253\230\351\242\221\345\205\203\347\264\240.md"
index 941c718d..6f53319f 100644
--- "a/Solutions/0347. \345\211\215 K \344\270\252\351\253\230\351\242\221\345\205\203\347\264\240.md"
+++ "b/Solutions/0347. \345\211\215 K \344\270\252\351\253\230\351\242\221\345\205\203\347\264\240.md"
@@ -19,14 +19,14 @@
- 示例 1:
-```Python
+```python
输入: nums = [1,1,1,2,2,3], k = 2
输出: [1,2]
```
- 示例 2:
-```Python
+```python
输入: nums = [1], k = 1
输出: [1]
```
@@ -44,7 +44,7 @@
### 思路 1:代码
-```Python
+```python
class Heapq:
# 堆调整方法:调整为大顶堆
def heapAdjust(self, nums: [int], nums_dict, index: int, end: int):
diff --git "a/Solutions/0349. \344\270\244\344\270\252\346\225\260\347\273\204\347\232\204\344\272\244\351\233\206.md" "b/Solutions/0349. \344\270\244\344\270\252\346\225\260\347\273\204\347\232\204\344\272\244\351\233\206.md"
index 96ea6817..0d6fcf05 100644
--- "a/Solutions/0349. \344\270\244\344\270\252\346\225\260\347\273\204\347\232\204\344\272\244\351\233\206.md"
+++ "b/Solutions/0349. \344\270\244\344\270\252\346\225\260\347\273\204\347\232\204\344\272\244\351\233\206.md"
@@ -18,7 +18,7 @@
- 示例 1:
-```Python
+```python
输入:nums1 = [1,2,2,1], nums2 = [2,2]
输出:[2]
示例 2:
@@ -26,7 +26,7 @@
- 示例 2:
-```Python
+```python
输入:nums1 = [4,9,5], nums2 = [9,4,9,8,4]
输出:[9,4]
解释:[4,9] 也是可通过的
@@ -41,7 +41,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def intersection(self, nums1: List[int], nums2: List[int]) -> List[int]:
numDict = dict()
@@ -72,7 +72,7 @@ class Solution:
### 思路 2:代码
-```Python
+```python
class Solution:
def intersection(self, nums1: List[int], nums2: List[int]) -> List[int]:
nums1.sort()
diff --git "a/Solutions/0350. \344\270\244\344\270\252\346\225\260\347\273\204\347\232\204\344\272\244\351\233\206 II.md" "b/Solutions/0350. \344\270\244\344\270\252\346\225\260\347\273\204\347\232\204\344\272\244\351\233\206 II.md"
index 44264fdd..29f04591 100644
--- "a/Solutions/0350. \344\270\244\344\270\252\346\225\260\347\273\204\347\232\204\344\272\244\351\233\206 II.md"
+++ "b/Solutions/0350. \344\270\244\344\270\252\346\225\260\347\273\204\347\232\204\344\272\244\351\233\206 II.md"
@@ -17,7 +17,7 @@
**示例**:
-```Python
+```python
输入:nums1 = [1,2,2,1], nums2 = [2,2]
输出:[2,2]
@@ -36,7 +36,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def intersect(self, nums1: List[int], nums2: List[int]) -> List[int]:
numDict = dict()
diff --git "a/Solutions/0351. \345\256\211\345\215\223\347\263\273\347\273\237\346\211\213\345\212\277\350\247\243\351\224\201.md" "b/Solutions/0351. \345\256\211\345\215\223\347\263\273\347\273\237\346\211\213\345\212\277\350\247\243\351\224\201.md"
index 91d640ed..01872dab 100644
--- "a/Solutions/0351. \345\256\211\345\215\223\347\263\273\347\273\237\346\211\213\345\212\277\350\247\243\351\224\201.md"
+++ "b/Solutions/0351. \345\256\211\345\215\223\347\263\273\347\273\237\346\211\213\345\212\277\350\247\243\351\224\201.md"
@@ -29,14 +29,14 @@
- 示例 1:
-```Python
+```python
输入:m = 1, n = 1
输出:9
```
- 示例 2:
-```Python
+```python
输入:m = 1, n = 2
输出:65
```
@@ -62,7 +62,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def numberOfPatterns(self, m: int, n: int) -> int:
# 将手势轨迹跨过点的情况存入哈希表中
diff --git "a/Solutions/0354. \344\277\204\347\275\227\346\226\257\345\245\227\345\250\203\344\277\241\345\260\201\351\227\256\351\242\230.md" "b/Solutions/0354. \344\277\204\347\275\227\346\226\257\345\245\227\345\250\203\344\277\241\345\260\201\351\227\256\351\242\230.md"
index 75e21cd0..93907937 100644
--- "a/Solutions/0354. \344\277\204\347\275\227\346\226\257\345\245\227\345\250\203\344\277\241\345\260\201\351\227\256\351\242\230.md"
+++ "b/Solutions/0354. \344\277\204\347\275\227\346\226\257\345\245\227\345\250\203\344\277\241\345\260\201\351\227\256\351\242\230.md"
@@ -37,7 +37,7 @@
## 代码
-```Python
+```python
class Solution:
def maxEnvelopes(self, envelopes: List[List[int]]) -> int:
if not envelopes:
diff --git "a/Solutions/0357. \347\273\237\350\256\241\345\220\204\344\275\215\346\225\260\345\255\227\351\203\275\344\270\215\345\220\214\347\232\204\346\225\260\345\255\227\344\270\252\346\225\260.md" "b/Solutions/0357. \347\273\237\350\256\241\345\220\204\344\275\215\346\225\260\345\255\227\351\203\275\344\270\215\345\220\214\347\232\204\346\225\260\345\255\227\344\270\252\346\225\260.md"
index 6b1b5307..8d78168b 100644
--- "a/Solutions/0357. \347\273\237\350\256\241\345\220\204\344\275\215\346\225\260\345\255\227\351\203\275\344\270\215\345\220\214\347\232\204\346\225\260\345\255\227\344\270\252\346\225\260.md"
+++ "b/Solutions/0357. \347\273\237\350\256\241\345\220\204\344\275\215\346\225\260\345\255\227\351\203\275\344\270\215\345\220\214\347\232\204\346\225\260\345\255\227\344\270\252\346\225\260.md"
@@ -18,7 +18,7 @@
- 示例 1:
-```Python
+```python
输入:n = 2
输出:91
解释:答案应为除去 11、22、33、44、55、66、77、88、99 外,在 0 ≤ x < 100 范围内的所有数字。
@@ -26,7 +26,7 @@
- 示例 2:
-```Python
+```python
输入:n = 0
输出:1
```
@@ -58,7 +58,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def countNumbersWithUniqueDigits(self, n: int) -> int:
s = str(10 ** n - 1)
diff --git "a/Solutions/0359. \346\227\245\345\277\227\351\200\237\347\216\207\351\231\220\345\210\266\345\231\250.md" "b/Solutions/0359. \346\227\245\345\277\227\351\200\237\347\216\207\351\231\220\345\210\266\345\231\250.md"
index 880a2cde..ebd214a2 100644
--- "a/Solutions/0359. \346\227\245\345\277\227\351\200\237\347\216\207\351\231\220\345\210\266\345\231\250.md"
+++ "b/Solutions/0359. \346\227\245\345\277\227\351\200\237\347\216\207\351\231\220\345\210\266\345\231\250.md"
@@ -25,7 +25,7 @@
## 代码
-```Python
+```python
class Logger:
def __init__(self):
diff --git "a/Solutions/0360. \346\234\211\345\272\217\350\275\254\345\214\226\346\225\260\347\273\204.md" "b/Solutions/0360. \346\234\211\345\272\217\350\275\254\345\214\226\346\225\260\347\273\204.md"
index 17a57142..52e09529 100644
--- "a/Solutions/0360. \346\234\211\345\272\217\350\275\254\345\214\226\346\225\260\347\273\204.md"
+++ "b/Solutions/0360. \346\234\211\345\272\217\350\275\254\345\214\226\346\225\260\347\273\204.md"
@@ -37,7 +37,7 @@
## 代码
-```Python
+```python
class Solution:
def calFormula(self, x, a, b, c):
return a * x * x + b * x + c
diff --git "a/Solutions/0367. \346\234\211\346\225\210\347\232\204\345\256\214\345\205\250\345\271\263\346\226\271\346\225\260.md" "b/Solutions/0367. \346\234\211\346\225\210\347\232\204\345\256\214\345\205\250\345\271\263\346\226\271\346\225\260.md"
index 4b55e202..4918d62c 100644
--- "a/Solutions/0367. \346\234\211\346\225\210\347\232\204\345\256\214\345\205\250\345\271\263\346\226\271\346\225\260.md"
+++ "b/Solutions/0367. \346\234\211\346\225\210\347\232\204\345\256\214\345\205\250\345\271\263\346\226\271\346\225\260.md"
@@ -15,7 +15,7 @@ x 可以通过二分查找得到。
## 代码
-```Python
+```python
class Solution:
def isPerfectSquare(self, num: int) -> bool:
left = 0
diff --git "a/Solutions/0370. \345\214\272\351\227\264\345\212\240\346\263\225.md" "b/Solutions/0370. \345\214\272\351\227\264\345\212\240\346\263\225.md"
index 50d719eb..c56f94da 100644
--- "a/Solutions/0370. \345\214\272\351\227\264\345\212\240\346\263\225.md"
+++ "b/Solutions/0370. \345\214\272\351\227\264\345\212\240\346\263\225.md"
@@ -34,7 +34,7 @@
### 思路 1:线段树代码
-```Python
+```python
# 线段树的节点类
class SegTreeNode:
def __init__(self, val=0):
diff --git "a/Solutions/0371. \344\270\244\346\225\264\346\225\260\344\271\213\345\222\214.md" "b/Solutions/0371. \344\270\244\346\225\264\346\225\260\344\271\213\345\222\214.md"
index 29462a3f..f4257ed7 100644
--- "a/Solutions/0371. \344\270\244\346\225\264\346\225\260\344\271\213\345\222\214.md"
+++ "b/Solutions/0371. \344\270\244\346\225\264\346\225\260\344\271\213\345\222\214.md"
@@ -27,7 +27,7 @@
## 代码
-```Python
+```python
class Solution:
def getSum(self, a: int, b: int) -> int:
MAX_INT = 0x7FFFFFFF
diff --git "a/Solutions/0374. \347\214\234\346\225\260\345\255\227\345\244\247\345\260\217.md" "b/Solutions/0374. \347\214\234\346\225\260\345\255\227\345\244\247\345\260\217.md"
index f3abf844..03ef1715 100644
--- "a/Solutions/0374. \347\214\234\346\225\260\345\255\227\345\244\247\345\260\217.md"
+++ "b/Solutions/0374. \347\214\234\346\225\260\345\255\227\345\244\247\345\260\217.md"
@@ -20,7 +20,7 @@
- 示例 1:
-```Python
+```python
输入:n = 10, pick = 6
输出:6
```
@@ -37,7 +37,7 @@
### 思路 1:二分查找代码
-```Python
+```python
class Solution:
def guessNumber(self, n: int) -> int:
left = 1
diff --git "a/Solutions/0375. \347\214\234\346\225\260\345\255\227\345\244\247\345\260\217 II.md" "b/Solutions/0375. \347\214\234\346\225\260\345\255\227\345\244\247\345\260\217 II.md"
index f61f4c7e..114543a3 100644
--- "a/Solutions/0375. \347\214\234\346\225\260\345\255\227\345\244\247\345\260\217 II.md"
+++ "b/Solutions/0375. \347\214\234\346\225\260\345\255\227\345\244\247\345\260\217 II.md"
@@ -27,7 +27,7 @@

-```Python
+```python
输入:n = 10
输出:16
解释:制胜策略如下:
@@ -51,7 +51,7 @@
- 示例 2:
-```Python
+```python
输入:n = 2
输出:1
解释:有两个可能的数字 1 和 2 。
@@ -112,7 +112,7 @@ $dp[i][j] = min_{x = i}^{x = j} \lbrace max \lbrace dp[i][x - 1], dp[x + 1][j] \
### 思路 1:代码
-```Python
+```python
class Solution:
def getMoneyAmount(self, n: int) -> int:
dp = [[0 for _ in range(n + 2)] for _ in range(n + 2)]
diff --git "a/Solutions/0376. \346\221\206\345\212\250\345\272\217\345\210\227.md" "b/Solutions/0376. \346\221\206\345\212\250\345\272\217\345\210\227.md"
index 7b01ce47..bcfcd931 100644
--- "a/Solutions/0376. \346\221\206\345\212\250\345\272\217\345\210\227.md"
+++ "b/Solutions/0376. \346\221\206\345\212\250\345\272\217\345\210\227.md"
@@ -45,7 +45,7 @@
## 代码
-```Python
+```python
class Solution:
def wiggleMaxLength(self, nums: List[int]) -> int:
size = len(nums)
diff --git "a/Solutions/0377. \347\273\204\345\220\210\346\200\273\345\222\214 \342\205\243.md" "b/Solutions/0377. \347\273\204\345\220\210\346\200\273\345\222\214 \342\205\243.md"
index 59e996b1..832a17b0 100644
--- "a/Solutions/0377. \347\273\204\345\220\210\346\200\273\345\222\214 \342\205\243.md"
+++ "b/Solutions/0377. \347\273\204\345\220\210\346\200\273\345\222\214 \342\205\243.md"
@@ -21,7 +21,7 @@
- 示例 1:
-```Python
+```python
输入:nums = [1,2,3], target = 4
输出:7
解释:
@@ -38,7 +38,7 @@
- 示例 2:
-```Python
+```python
输入:nums = [9], target = 3
输出:0
```
@@ -53,7 +53,7 @@
我们需要在考虑某一总和 $w$ 时,需要将 $nums$ 中所有元素都考虑到。对应到循环关系时,即将总和 $w$ 的遍历放到外侧循环,将 $nums$ 数组元素的遍历放到内侧循环,即:
-```Python
+```python
for w in range(target + 1):
for i in range(1, len(nums) + 1):
xxxx
@@ -81,7 +81,7 @@ for w in range(target + 1):
### 思路 1:代码
-```Python
+```python
class Solution:
def combinationSum4(self, nums: List[int], target: int) -> int:
size = len(nums)
diff --git "a/Solutions/0378. \346\234\211\345\272\217\347\237\251\351\230\265\344\270\255\347\254\254 K \345\260\217\347\232\204\345\205\203\347\264\240.md" "b/Solutions/0378. \346\234\211\345\272\217\347\237\251\351\230\265\344\270\255\347\254\254 K \345\260\217\347\232\204\345\205\203\347\264\240.md"
index a5f06570..254620a7 100644
--- "a/Solutions/0378. \346\234\211\345\272\217\347\237\251\351\230\265\344\270\255\347\254\254 K \345\260\217\347\232\204\345\205\203\347\264\240.md"
+++ "b/Solutions/0378. \346\234\211\345\272\217\347\237\251\351\230\265\344\270\255\347\254\254 K \345\260\217\347\232\204\345\205\203\347\264\240.md"
@@ -22,7 +22,7 @@
## 代码
-```Python
+```python
class Solution:
def kthSmallest(self, matrix: List[List[int]], k: int) -> int:
rows, cols = len(matrix), len(matrix[0])
diff --git "a/Solutions/0380. O(1) \346\227\266\351\227\264\346\217\222\345\205\245\343\200\201\345\210\240\351\231\244\345\222\214\350\216\267\345\217\226\351\232\217\346\234\272\345\205\203\347\264\240.md" "b/Solutions/0380. O(1) \346\227\266\351\227\264\346\217\222\345\205\245\343\200\201\345\210\240\351\231\244\345\222\214\350\216\267\345\217\226\351\232\217\346\234\272\345\205\203\347\264\240.md"
index 5aeba634..c59b91d3 100644
--- "a/Solutions/0380. O(1) \346\227\266\351\227\264\346\217\222\345\205\245\343\200\201\345\210\240\351\231\244\345\222\214\350\216\267\345\217\226\351\232\217\346\234\272\345\205\203\347\264\240.md"
+++ "b/Solutions/0380. O(1) \346\227\266\351\227\264\346\217\222\345\205\245\343\200\201\345\210\240\351\231\244\345\222\214\350\216\267\345\217\226\351\232\217\346\234\272\345\205\203\347\264\240.md"
@@ -21,7 +21,7 @@
## 代码
-```Python
+```python
import random
class RandomizedSet:
diff --git "a/Solutions/0383. \350\265\216\351\207\221\344\277\241.md" "b/Solutions/0383. \350\265\216\351\207\221\344\277\241.md"
index 99aad9a6..8c1043cb 100644
--- "a/Solutions/0383. \350\265\216\351\207\221\344\277\241.md"
+++ "b/Solutions/0383. \350\265\216\351\207\221\344\277\241.md"
@@ -25,7 +25,7 @@
## 代码
-```Python
+```python
class Solution:
def canConstruct(self, ransomNote: str, magazine: str) -> bool:
magazine_counts = [0 for _ in range(26)]
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"
index 7907bd43..fcd2c6eb 100644
--- "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"
@@ -26,7 +26,7 @@
- 示例 1:
-```Python
+```python
输入:
["Solution", "shuffle", "reset", "shuffle"]
[[[1, 2, 3]], [], [], []]
@@ -53,7 +53,7 @@ solution.shuffle(); // 随机返回数组 [1, 2, 3] 打乱后的结果。例
### 思路 1:洗牌算法代码
-```Python
+```python
class Solution:
def __init__(self, nums: List[int]):
diff --git "a/Solutions/0386. \345\255\227\345\205\270\345\272\217\346\216\222\346\225\260.md" "b/Solutions/0386. \345\255\227\345\205\270\345\272\217\346\216\222\346\225\260.md"
index 85245b43..9c151657 100644
--- "a/Solutions/0386. \345\255\227\345\205\270\345\272\217\346\216\222\346\225\260.md"
+++ "b/Solutions/0386. \345\255\227\345\205\270\345\272\217\346\216\222\346\225\260.md"
@@ -15,7 +15,7 @@
## 代码
-```Python
+```python
class Solution:
def dfs(self, cur, n, res):
if cur > n:
diff --git "a/Solutions/0387. \345\255\227\347\254\246\344\270\262\344\270\255\347\232\204\347\254\254\344\270\200\344\270\252\345\224\257\344\270\200\345\255\227\347\254\246.md" "b/Solutions/0387. \345\255\227\347\254\246\344\270\262\344\270\255\347\232\204\347\254\254\344\270\200\344\270\252\345\224\257\344\270\200\345\255\227\347\254\246.md"
index 2c4ca1cb..334a01f6 100644
--- "a/Solutions/0387. \345\255\227\347\254\246\344\270\262\344\270\255\347\232\204\347\254\254\344\270\200\344\270\252\345\224\257\344\270\200\345\255\227\347\254\246.md"
+++ "b/Solutions/0387. \345\255\227\347\254\246\344\270\262\344\270\255\347\232\204\347\254\254\344\270\200\344\270\252\345\224\257\344\270\200\345\255\227\347\254\246.md"
@@ -15,7 +15,7 @@
## 代码
-```Python
+```python
class Solution:
def firstUniqChar(self, s: str) -> int:
strDict = dict()
diff --git "a/Solutions/0389. \346\211\276\344\270\215\345\220\214.md" "b/Solutions/0389. \346\211\276\344\270\215\345\220\214.md"
index 7bbdee63..72b6920e 100644
--- "a/Solutions/0389. \346\211\276\344\270\215\345\220\214.md"
+++ "b/Solutions/0389. \346\211\276\344\270\215\345\220\214.md"
@@ -13,7 +13,7 @@
## 代码
-```Python
+```python
class Solution:
def findTheDifference(self, s: str, t: str) -> str:
s_dict = dict()
diff --git "a/Solutions/0391. \345\256\214\347\276\216\347\237\251\345\275\242.md" "b/Solutions/0391. \345\256\214\347\276\216\347\237\251\345\275\242.md"
index adffc75c..0f472859 100644
--- "a/Solutions/0391. \345\256\214\347\276\216\347\237\251\345\275\242.md"
+++ "b/Solutions/0391. \345\256\214\347\276\216\347\237\251\345\275\242.md"
@@ -21,7 +21,7 @@

-```Python
+```python
输入:rectangles = [[1,1,3,3],[3,1,4,2],[3,2,4,4],[1,3,2,4],[2,3,3,4]]
输出:True
解释:5 个矩形一起可以精确地覆盖一个矩形区域。
@@ -31,7 +31,7 @@

-```Python
+```python
输入:rectangles = [[1,1,2,3],[1,3,2,4],[3,1,4,2],[3,2,4,4]]
输出:false
解释:两个矩形之间有间隔,无法覆盖成一个矩形。
@@ -41,7 +41,7 @@

-```Python
+```python
输入:rectangles = [[1,1,3,3],[3,1,4,2],[1,3,2,4],[2,2,4,4]]
输出:False
解释:因为中间有相交区域,虽然形成了矩形,但不是精确覆盖。
@@ -77,7 +77,7 @@
### 思路 1:线段树代码
-```Python
+```python
# 线段树的节点类
class SegTreeNode:
def __init__(self, val=0):
diff --git "a/Solutions/0392. \345\210\244\346\226\255\345\255\220\345\272\217\345\210\227.md" "b/Solutions/0392. \345\210\244\346\226\255\345\255\220\345\272\217\345\210\227.md"
index ceec129f..0e3569b4 100644
--- "a/Solutions/0392. \345\210\244\346\226\255\345\255\220\345\272\217\345\210\227.md"
+++ "b/Solutions/0392. \345\210\244\346\226\255\345\255\220\345\272\217\345\210\227.md"
@@ -20,7 +20,7 @@
## 代码
-```Python
+```python
class Solution:
def isSubsequence(self, s: str, t: str) -> bool:
size_s = len(s)
diff --git "a/Solutions/0394. \345\255\227\347\254\246\344\270\262\350\247\243\347\240\201.md" "b/Solutions/0394. \345\255\227\347\254\246\344\270\262\350\247\243\347\240\201.md"
index 2734e58d..039d9c1b 100644
--- "a/Solutions/0394. \345\255\227\347\254\246\344\270\262\350\247\243\347\240\201.md"
+++ "b/Solutions/0394. \345\255\227\347\254\246\344\270\262\350\247\243\347\240\201.md"
@@ -21,14 +21,14 @@
- 示例 1:
-```Python
+```python
输入:s = "3[a]2[bc]"
输出:"aaabcbc"
```
- 示例 2:
-```Python
+```python
输入:s = "3[a2[c]]"
输出:"accaccacc"
```
@@ -48,7 +48,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def decodeString(self, s: str) -> str:
stack1 = []
diff --git "a/Solutions/0395. \350\207\263\345\260\221\346\234\211 K \344\270\252\351\207\215\345\244\215\345\255\227\347\254\246\347\232\204\346\234\200\351\225\277\345\255\220\344\270\262.md" "b/Solutions/0395. \350\207\263\345\260\221\346\234\211 K \344\270\252\351\207\215\345\244\215\345\255\227\347\254\246\347\232\204\346\234\200\351\225\277\345\255\220\344\270\262.md"
index 40d2ee16..71747a91 100644
--- "a/Solutions/0395. \350\207\263\345\260\221\346\234\211 K \344\270\252\351\207\215\345\244\215\345\255\227\347\254\246\347\232\204\346\234\200\351\225\277\345\255\220\344\270\262.md"
+++ "b/Solutions/0395. \350\207\263\345\260\221\346\234\211 K \344\270\252\351\207\215\345\244\215\345\255\227\347\254\246\347\232\204\346\234\200\351\225\277\345\255\220\344\270\262.md"
@@ -36,7 +36,7 @@
## 代码
-```Python
+```python
class Solution:
def longestSubstring(self, s: str, k: int) -> int:
ans = 0
diff --git "a/Solutions/0399. \351\231\244\346\263\225\346\261\202\345\200\274.md" "b/Solutions/0399. \351\231\244\346\263\225\346\261\202\345\200\274.md"
index de84bb4f..af543ba3 100644
--- "a/Solutions/0399. \351\231\244\346\263\225\346\261\202\345\200\274.md"
+++ "b/Solutions/0399. \351\231\244\346\263\225\346\261\202\345\200\274.md"
@@ -42,7 +42,7 @@
## 代码
-```Python
+```python
class UnionFind:
def __init__(self, n):
diff --git "a/Solutions/0400. \347\254\254 N \344\275\215\346\225\260\345\255\227.md" "b/Solutions/0400. \347\254\254 N \344\275\215\346\225\260\345\255\227.md"
index 8acddc89..196ab39b 100644
--- "a/Solutions/0400. \347\254\254 N \344\275\215\346\225\260\345\255\227.md"
+++ "b/Solutions/0400. \347\254\254 N \344\275\215\346\225\260\345\255\227.md"
@@ -26,7 +26,7 @@
## 代码
-```Python
+```python
class Solution:
def findNthDigit(self, n: int) -> int:
digits = 1
diff --git "a/Solutions/0403. \351\235\222\350\233\231\350\277\207\346\262\263.md" "b/Solutions/0403. \351\235\222\350\233\231\350\277\207\346\262\263.md"
index 24b369af..0788463e 100644
--- "a/Solutions/0403. \351\235\222\350\233\231\350\277\207\346\262\263.md"
+++ "b/Solutions/0403. \351\235\222\350\233\231\350\277\207\346\262\263.md"
@@ -26,7 +26,7 @@
- 示例 1:
-```Python
+```python
输入:stones = [0,1,3,5,6,8,12,17]
输出:true
解释:青蛙可以成功过河,按照如下方案跳跃:跳 1 个单位到第 2 块石子, 然后跳 2 个单位到第 3 块石子, 接着 跳 2 个单位到第 4 块石子, 然后跳 3 个单位到第 6 块石子, 跳 4 个单位到第 7 块石子, 最后,跳 5 个单位到第 8 个石子(即最后一块石子)。
@@ -69,7 +69,7 @@
### 思路 1:动态规划代码
-```Python
+```python
class Solution:
def canCross(self, stones: List[int]) -> bool:
size = len(stones)
diff --git "a/Solutions/0404. \345\267\246\345\217\266\345\255\220\344\271\213\345\222\214.md" "b/Solutions/0404. \345\267\246\345\217\266\345\255\220\344\271\213\345\222\214.md"
index 67fed660..f57f06fc 100644
--- "a/Solutions/0404. \345\267\246\345\217\266\345\255\220\344\271\213\345\222\214.md"
+++ "b/Solutions/0404. \345\267\246\345\217\266\345\255\220\344\271\213\345\222\214.md"
@@ -13,7 +13,7 @@
## 代码
-```Python
+```python
class Solution:
def sumOfLeftLeaves(self, root: TreeNode) -> int:
self.ans = 0
diff --git "a/Solutions/0405. \346\225\260\345\255\227\350\275\254\346\215\242\344\270\272\345\215\201\345\205\255\350\277\233\345\210\266\346\225\260.md" "b/Solutions/0405. \346\225\260\345\255\227\350\275\254\346\215\242\344\270\272\345\215\201\345\205\255\350\277\233\345\210\266\346\225\260.md"
index 57a7abf1..1c53cfbc 100644
--- "a/Solutions/0405. \346\225\260\345\255\227\350\275\254\346\215\242\344\270\272\345\215\201\345\205\255\350\277\233\345\210\266\346\225\260.md"
+++ "b/Solutions/0405. \346\225\260\345\255\227\350\275\254\346\215\242\344\270\272\345\215\201\345\205\255\350\277\233\345\210\266\346\225\260.md"
@@ -28,7 +28,7 @@
## 代码
-```Python
+```python
class Solution:
def toHex(self, num: int) -> str:
res = ''
diff --git "a/Solutions/0406. \346\240\271\346\215\256\350\272\253\351\253\230\351\207\215\345\273\272\351\230\237\345\210\227.md" "b/Solutions/0406. \346\240\271\346\215\256\350\272\253\351\253\230\351\207\215\345\273\272\351\230\237\345\210\227.md"
index 2de866ca..f6fd40a1 100644
--- "a/Solutions/0406. \346\240\271\346\215\256\350\272\253\351\253\230\351\207\215\345\273\272\351\230\237\345\210\227.md"
+++ "b/Solutions/0406. \346\240\271\346\215\256\350\272\253\351\253\230\351\207\215\345\273\272\351\230\237\345\210\227.md"
@@ -19,7 +19,7 @@ n 个人打乱顺序排成一排,给定一个数组 people 表示队列中人
## 代码
-```Python
+```python
class Solution:
def reconstructQueue(self, people: List[List[int]]) -> List[List[int]]:
queue = []
diff --git "a/Solutions/0409. \346\234\200\351\225\277\345\233\236\346\226\207\344\270\262.md" "b/Solutions/0409. \346\234\200\351\225\277\345\233\236\346\226\207\344\270\262.md"
index 96e8ac25..3d40944d 100644
--- "a/Solutions/0409. \346\234\200\351\225\277\345\233\236\346\226\207\344\270\262.md"
+++ "b/Solutions/0409. \346\234\200\351\225\277\345\233\236\346\226\207\344\270\262.md"
@@ -22,7 +22,7 @@
## 代码
-```Python
+```python
class Solution:
def longestPalindrome(self, s: str) -> int:
word_dict = dict()
diff --git "a/Solutions/0410. \345\210\206\345\211\262\346\225\260\347\273\204\347\232\204\346\234\200\345\244\247\345\200\274.md" "b/Solutions/0410. \345\210\206\345\211\262\346\225\260\347\273\204\347\232\204\346\234\200\345\244\247\345\200\274.md"
index 781781b6..eb339c0c 100644
--- "a/Solutions/0410. \345\210\206\345\211\262\346\225\260\347\273\204\347\232\204\346\234\200\345\244\247\345\200\274.md"
+++ "b/Solutions/0410. \345\210\206\345\211\262\346\225\260\347\273\204\347\232\204\346\234\200\345\244\247\345\200\274.md"
@@ -21,7 +21,7 @@
## 代码
-```Python
+```python
class Solution:
def splitArray(self, nums: List[int], m: int) -> int:
def get_count(x):
diff --git a/Solutions/0412. Fizz Buzz.md b/Solutions/0412. Fizz Buzz.md
index 220f20e0..1ee3422c 100644
--- a/Solutions/0412. Fizz Buzz.md
+++ b/Solutions/0412. Fizz Buzz.md
@@ -19,7 +19,7 @@
## 代码
-```Python
+```python
class Solution:
def fizzBuzz(self, n: int) -> List[str]:
ans = []
diff --git "a/Solutions/0415. \345\255\227\347\254\246\344\270\262\347\233\270\345\212\240.md" "b/Solutions/0415. \345\255\227\347\254\246\344\270\262\347\233\270\345\212\240.md"
index f994fdcb..6cf66ba9 100644
--- "a/Solutions/0415. \345\255\227\347\254\246\344\270\262\347\233\270\345\212\240.md"
+++ "b/Solutions/0415. \345\255\227\347\254\246\344\270\262\347\233\270\345\212\240.md"
@@ -20,14 +20,14 @@
- 示例 1:
-```Python
+```python
输入:num1 = "11", num2 = "123"
输出:"134"
```
- 示例 2:
-```Python
+```python
输入:num1 = "456", num2 = "77"
输出:"533"
```
@@ -50,7 +50,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def addStrings(self, num1: str, num2: str) -> str:
# num1 位数
diff --git "a/Solutions/0416. \345\210\206\345\211\262\347\255\211\345\222\214\345\255\220\351\233\206.md" "b/Solutions/0416. \345\210\206\345\211\262\347\255\211\345\222\214\345\255\220\351\233\206.md"
index ded2f59d..40ce05b3 100644
--- "a/Solutions/0416. \345\210\206\345\211\262\347\255\211\345\222\214\345\255\220\351\233\206.md"
+++ "b/Solutions/0416. \345\210\206\345\211\262\347\255\211\345\222\214\345\255\220\351\233\206.md"
@@ -18,7 +18,7 @@
- 示例 1:
-```Python
+```python
输入:nums = [1,5,11,5]
输出:true
解释:数组可以分割成 [1, 5, 5] 和 [11]。
@@ -26,7 +26,7 @@
- 示例 2:
-```Python
+```python
输入:nums = [1,2,3,5]
输出:false
解释:数组不能分割成两个元素和相等的子集。
@@ -71,7 +71,7 @@ $dp[w] = \begin{cases} dp[w] & w < nums[i - 1] \cr max \lbrace dp[w], \quad dp[w
### 思路 1:代码
-```Python
+```python
class Solution:
# 思路 2:动态规划 + 滚动数组优化
def zeroOnePackMethod2(self, weight: [int], value: [int], W: int):
diff --git "a/Solutions/0417. \345\244\252\345\271\263\346\264\213\345\244\247\350\245\277\346\264\213\346\260\264\346\265\201\351\227\256\351\242\230.md" "b/Solutions/0417. \345\244\252\345\271\263\346\264\213\345\244\247\350\245\277\346\264\213\346\260\264\346\265\201\351\227\256\351\242\230.md"
index 9c517b4c..f678adaa 100644
--- "a/Solutions/0417. \345\244\252\345\271\263\346\264\213\345\244\247\350\245\277\346\264\213\346\260\264\346\265\201\351\227\256\351\242\230.md"
+++ "b/Solutions/0417. \345\244\252\345\271\263\346\264\213\345\244\247\350\245\277\346\264\213\346\260\264\346\265\201\351\227\256\351\242\230.md"
@@ -22,14 +22,14 @@

-```Python
+```python
输入: heights = [[1,2,2,3,5],[3,2,3,4,4],[2,4,5,3,1],[6,7,1,4,5],[5,1,1,2,4]]
输出: [[0,4],[1,3],[1,4],[2,2],[3,0],[3,1],[4,0]]
```
- 示例 2:
-```Python
+```python
输入: heights = [[2,1],[1,2]]
输出: [[0,0],[0,1],[1,0],[1,1]]
```
@@ -46,7 +46,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def pacificAtlantic(self, heights: List[List[int]]) -> List[List[int]]:
rows, cols = len(heights), len(heights[0])
diff --git "a/Solutions/0421. \346\225\260\347\273\204\344\270\255\344\270\244\344\270\252\346\225\260\347\232\204\346\234\200\345\244\247\345\274\202\346\210\226\345\200\274.md" "b/Solutions/0421. \346\225\260\347\273\204\344\270\255\344\270\244\344\270\252\346\225\260\347\232\204\346\234\200\345\244\247\345\274\202\346\210\226\345\200\274.md"
index 73c198ba..03f6e7b8 100644
--- "a/Solutions/0421. \346\225\260\347\273\204\344\270\255\344\270\244\344\270\252\346\225\260\347\232\204\346\234\200\345\244\247\345\274\202\346\210\226\345\200\274.md"
+++ "b/Solutions/0421. \346\225\260\347\273\204\344\270\255\344\270\244\344\270\252\346\225\260\347\232\204\346\234\200\345\244\247\345\274\202\346\210\226\345\200\274.md"
@@ -21,7 +21,7 @@
## 代码
-```Python
+```python
class Trie:
def __init__(self):
diff --git "a/Solutions/0424. \346\233\277\346\215\242\345\220\216\347\232\204\346\234\200\351\225\277\351\207\215\345\244\215\345\255\227\347\254\246.md" "b/Solutions/0424. \346\233\277\346\215\242\345\220\216\347\232\204\346\234\200\351\225\277\351\207\215\345\244\215\345\255\227\347\254\246.md"
index 7fed8ff6..aba387dd 100644
--- "a/Solutions/0424. \346\233\277\346\215\242\345\220\216\347\232\204\346\234\200\351\225\277\351\207\215\345\244\215\345\255\227\347\254\246.md"
+++ "b/Solutions/0424. \346\233\277\346\215\242\345\220\216\347\232\204\346\234\200\351\225\277\351\207\215\345\244\215\345\255\227\347\254\246.md"
@@ -24,7 +24,7 @@
## 代码
-```Python
+```python
class Solution:
def characterReplacement(self, s: str, k: int) -> int:
max_count = 0
diff --git "a/Solutions/0425. \345\215\225\350\257\215\346\226\271\345\235\227.md" "b/Solutions/0425. \345\215\225\350\257\215\346\226\271\345\235\227.md"
index c01d6450..5628fa35 100644
--- "a/Solutions/0425. \345\215\225\350\257\215\346\226\271\345\235\227.md"
+++ "b/Solutions/0425. \345\215\225\350\257\215\346\226\271\345\235\227.md"
@@ -34,7 +34,7 @@ l a d y
## 代码
-```Python
+```python
class Trie:
def __init__(self):
diff --git "a/Solutions/0426. \345\260\206\344\272\214\345\217\211\346\220\234\347\264\242\346\240\221\350\275\254\345\214\226\344\270\272\346\216\222\345\272\217\347\232\204\345\217\214\345\220\221\351\223\276\350\241\250.md" "b/Solutions/0426. \345\260\206\344\272\214\345\217\211\346\220\234\347\264\242\346\240\221\350\275\254\345\214\226\344\270\272\346\216\222\345\272\217\347\232\204\345\217\214\345\220\221\351\223\276\350\241\250.md"
index ebf8ea09..f51214a0 100644
--- "a/Solutions/0426. \345\260\206\344\272\214\345\217\211\346\220\234\347\264\242\346\240\221\350\275\254\345\214\226\344\270\272\346\216\222\345\272\217\347\232\204\345\217\214\345\220\221\351\223\276\350\241\250.md"
+++ "b/Solutions/0426. \345\260\206\344\272\214\345\217\211\346\220\234\347\264\242\346\240\221\350\275\254\345\214\226\344\270\272\346\216\222\345\272\217\347\232\204\345\217\214\345\220\221\351\223\276\350\241\250.md"
@@ -26,7 +26,7 @@
## 代码
-```Python
+```python
class Solution:
def treeToDoublyList(self, root: 'Node') -> 'Node':
def dfs(node: 'Node'):
diff --git "a/Solutions/0428. \345\272\217\345\210\227\345\214\226\345\222\214\345\217\215\345\272\217\345\210\227\345\214\226 N \345\217\211\346\240\221.md" "b/Solutions/0428. \345\272\217\345\210\227\345\214\226\345\222\214\345\217\215\345\272\217\345\210\227\345\214\226 N \345\217\211\346\240\221.md"
index bf59bf2e..ce8ae971 100644
--- "a/Solutions/0428. \345\272\217\345\210\227\345\214\226\345\222\214\345\217\215\345\272\217\345\210\227\345\214\226 N \345\217\211\346\240\221.md"
+++ "b/Solutions/0428. \345\272\217\345\210\227\345\214\226\345\222\214\345\217\215\345\272\217\345\210\227\345\214\226 N \345\217\211\346\240\221.md"
@@ -19,7 +19,7 @@
## 代码
-```Python
+```python
class Codec:
def serialize(self, root: 'Node') -> str:
"""Encodes a tree to a single string.
diff --git "a/Solutions/0429. N \345\217\211\346\240\221\347\232\204\345\261\202\345\272\217\351\201\215\345\216\206.md" "b/Solutions/0429. N \345\217\211\346\240\221\347\232\204\345\261\202\345\272\217\351\201\215\345\216\206.md"
index c820126b..485de8d7 100644
--- "a/Solutions/0429. N \345\217\211\346\240\221\347\232\204\345\261\202\345\272\217\351\201\215\345\216\206.md"
+++ "b/Solutions/0429. N \345\217\211\346\240\221\347\232\204\345\261\202\345\272\217\351\201\215\345\216\206.md"
@@ -23,7 +23,7 @@
## 代码
-```Python
+```python
class Solution:
def levelOrder(self, root: 'Node') -> List[List[int]]:
ans = []
diff --git "a/Solutions/0430. \346\211\201\345\271\263\345\214\226\345\244\232\347\272\247\345\217\214\345\220\221\351\223\276\350\241\250.md" "b/Solutions/0430. \346\211\201\345\271\263\345\214\226\345\244\232\347\272\247\345\217\214\345\220\221\351\223\276\350\241\250.md"
index a54d3197..b472f8b1 100644
--- "a/Solutions/0430. \346\211\201\345\271\263\345\214\226\345\244\232\347\272\247\345\217\214\345\220\221\351\223\276\350\241\250.md"
+++ "b/Solutions/0430. \346\211\201\345\271\263\345\214\226\345\244\232\347\272\247\345\217\214\345\220\221\351\223\276\350\241\250.md"
@@ -28,7 +28,7 @@
## 代码
-```Python
+```python
class Solution:
def dfs(self, node: 'Node'):
# 找到链表的尾节点或 child 链表不为空的节点
diff --git "a/Solutions/0435. \346\227\240\351\207\215\345\217\240\345\214\272\351\227\264.md" "b/Solutions/0435. \346\227\240\351\207\215\345\217\240\345\214\272\351\227\264.md"
index c95eab67..7853fba7 100644
--- "a/Solutions/0435. \346\227\240\351\207\215\345\217\240\345\214\272\351\227\264.md"
+++ "b/Solutions/0435. \346\227\240\351\207\215\345\217\240\345\214\272\351\227\264.md"
@@ -19,7 +19,7 @@
- 示例 1:
-```Python
+```python
输入:intervals = [[1,2],[2,3],[3,4],[1,3]]
输出:1
解释:移除 [1,3] 后,剩下的区间没有重叠。
@@ -27,7 +27,7 @@
- 示例 2:
-```Python
+```python
输入: intervals = [ [1,2], [1,2], [1,2] ]
输出: 2
解释: 你需要移除两个 [1,2] 来使剩下的区间没有重叠。
@@ -56,7 +56,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def eraseOverlapIntervals(self, intervals: List[List[int]]) -> int:
if not intervals:
diff --git "a/Solutions/0437. \350\267\257\345\276\204\346\200\273\345\222\214 III.md" "b/Solutions/0437. \350\267\257\345\276\204\346\200\273\345\222\214 III.md"
index c720572e..b8be8681 100644
--- "a/Solutions/0437. \350\267\257\345\276\204\346\200\273\345\222\214 III.md"
+++ "b/Solutions/0437. \350\267\257\345\276\204\346\200\273\345\222\214 III.md"
@@ -35,7 +35,7 @@
## 代码
-```Python
+```python
class Solution:
prefixsum_count = dict()
diff --git "a/Solutions/0438. \346\211\276\345\210\260\345\255\227\347\254\246\344\270\262\344\270\255\346\211\200\346\234\211\345\255\227\346\257\215\345\274\202\344\275\215\350\257\215.md" "b/Solutions/0438. \346\211\276\345\210\260\345\255\227\347\254\246\344\270\262\344\270\255\346\211\200\346\234\211\345\255\227\346\257\215\345\274\202\344\275\215\350\257\215.md"
index d6f83a9a..cc7a38f1 100644
--- "a/Solutions/0438. \346\211\276\345\210\260\345\255\227\347\254\246\344\270\262\344\270\255\346\211\200\346\234\211\345\255\227\346\257\215\345\274\202\344\275\215\350\257\215.md"
+++ "b/Solutions/0438. \346\211\276\345\210\260\345\255\227\347\254\246\344\270\262\344\270\255\346\211\200\346\234\211\345\255\227\346\257\215\345\274\202\344\275\215\350\257\215.md"
@@ -26,7 +26,7 @@
## 代码
-```Python
+```python
class Solution:
def findAnagrams(self, s: str, p: str) -> List[int]:
need = collections.defaultdict(int)
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"
index b835d192..61681dde 100644
--- "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"
@@ -26,7 +26,7 @@
- 示例 1:
-```Python
+```python
输入:chars = ["a","a","b","b","c","c","c"]
输出:返回 6 ,输入数组的前 6 个字符应该是:["a","2","b","2","c","3"]
解释:"aa" 被 "a2" 替代。"bb" 被 "b2" 替代。"ccc" 被 "c3" 替代。
@@ -50,7 +50,7 @@
### 思路 1:快慢指针代码
-```Python
+```python
class Solution:
def compress(self, chars: List[str]) -> int:
diff --git "a/Solutions/0445. \344\270\244\346\225\260\347\233\270\345\212\240 II.md" "b/Solutions/0445. \344\270\244\346\225\260\347\233\270\345\212\240 II.md"
index 33a5cd3b..b821e36a 100644
--- "a/Solutions/0445. \344\270\244\346\225\260\347\233\270\345\212\240 II.md"
+++ "b/Solutions/0445. \344\270\244\346\225\260\347\233\270\345\212\240 II.md"
@@ -27,7 +27,7 @@
## 代码
-```Python
+```python
class Solution:
def addTwoNumbers(self, l1: ListNode, l2: ListNode) -> ListNode:
stack1, stack2 = [], []
diff --git "a/Solutions/0447. \345\233\236\346\227\213\351\225\226\347\232\204\346\225\260\351\207\217.md" "b/Solutions/0447. \345\233\236\346\227\213\351\225\226\347\232\204\346\225\260\351\207\217.md"
index ed7aa7a5..54b1419a 100644
--- "a/Solutions/0447. \345\233\236\346\227\213\351\225\226\347\232\204\346\225\260\351\207\217.md"
+++ "b/Solutions/0447. \345\233\236\346\227\213\351\225\226\347\232\204\346\225\260\351\207\217.md"
@@ -13,7 +13,7 @@
## 代码
-```Python
+```python
class Solution:
def numberOfBoomerangs(self, points: List[List[int]]) -> int:
ans = 0
diff --git "a/Solutions/0450. \345\210\240\351\231\244\344\272\214\345\217\211\346\220\234\347\264\242\346\240\221\344\270\255\347\232\204\350\212\202\347\202\271.md" "b/Solutions/0450. \345\210\240\351\231\244\344\272\214\345\217\211\346\220\234\347\264\242\346\240\221\344\270\255\347\232\204\350\212\202\347\202\271.md"
index 5dc2b080..e167afc9 100644
--- "a/Solutions/0450. \345\210\240\351\231\244\344\272\214\345\217\211\346\220\234\347\264\242\346\240\221\344\270\255\347\232\204\350\212\202\347\202\271.md"
+++ "b/Solutions/0450. \345\210\240\351\231\244\344\272\214\345\217\211\346\220\234\347\264\242\346\240\221\344\270\255\347\232\204\350\212\202\347\202\271.md"
@@ -23,7 +23,7 @@

-```Python
+```python
输入:root = [5,3,6,2,4,null,7], key = 3
输出:[5,4,6,2,null,null,7]
解释:给定需要删除的节点值是 3,所以我们首先找到 3 这个节点,然后删除它。
@@ -33,7 +33,7 @@
- 示例 2:
-```Python
+```python
输入: root = [5,3,6,2,4,null,7], key = 0
输出: [5,3,6,2,4,null,7]
解释: 二叉树不包含值为 0 的节点
@@ -56,7 +56,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def deleteNode(self, root: TreeNode, key: int) -> TreeNode:
if not root:
diff --git "a/Solutions/0451. \346\240\271\346\215\256\345\255\227\347\254\246\345\207\272\347\216\260\351\242\221\347\216\207\346\216\222\345\272\217.md" "b/Solutions/0451. \346\240\271\346\215\256\345\255\227\347\254\246\345\207\272\347\216\260\351\242\221\347\216\207\346\216\222\345\272\217.md"
index 22f20697..26359de3 100644
--- "a/Solutions/0451. \346\240\271\346\215\256\345\255\227\347\254\246\345\207\272\347\216\260\351\242\221\347\216\207\346\216\222\345\272\217.md"
+++ "b/Solutions/0451. \346\240\271\346\215\256\345\255\227\347\254\246\345\207\272\347\216\260\351\242\221\347\216\207\346\216\222\345\272\217.md"
@@ -18,7 +18,7 @@
- 示例 1:
-```Python
+```python
输入: s = "tree"
输出: "eert"
解释: 'e'出现两次,'r'和't'都只出现一次。
@@ -27,7 +27,7 @@
- 示例 2:
-```Python
+```python
输入: s = "cccaaa"
输出: "cccaaa"
解释: 'c'和'a'都出现三次。此外,"aaaccc"也是有效的答案。
@@ -45,7 +45,7 @@
### 思路 1:代码
-```Python
+```python
import heapq
class Solution:
diff --git "a/Solutions/0452. \347\224\250\346\234\200\345\260\221\346\225\260\351\207\217\347\232\204\347\256\255\345\274\225\347\210\206\346\260\224\347\220\203.md" "b/Solutions/0452. \347\224\250\346\234\200\345\260\221\346\225\260\351\207\217\347\232\204\347\256\255\345\274\225\347\210\206\346\260\224\347\220\203.md"
index bb92efad..0defaeed 100644
--- "a/Solutions/0452. \347\224\250\346\234\200\345\260\221\346\225\260\351\207\217\347\232\204\347\256\255\345\274\225\347\210\206\346\260\224\347\220\203.md"
+++ "b/Solutions/0452. \347\224\250\346\234\200\345\260\221\346\225\260\351\207\217\347\232\204\347\256\255\345\274\225\347\210\206\346\260\224\347\220\203.md"
@@ -23,7 +23,7 @@
- 示例 1:
-```Python
+```python
输入:points = [[10,16],[2,8],[1,6],[7,12]]
输出:2
解释:气球可以用 2 支箭来爆破:
@@ -33,7 +33,7 @@
- 示例 2:
-```Python
+```python
输入:points = [[1,2],[3,4],[5,6],[7,8]]
输出:4
解释:每个气球需要射出一支箭,总共需要 4 支箭。
@@ -79,7 +79,7 @@
1. 按照结束位置升序排序
-```Python
+```python
class Solution:
def findMinArrowShots(self, points: List[List[int]]) -> int:
if not points:
@@ -96,7 +96,7 @@ class Solution:
2. 按照开始位置升序排序
-```Python
+```python
class Solution:
def findMinArrowShots(self, points: List[List[int]]) -> int:
if not points:
diff --git "a/Solutions/0454. \345\233\233\346\225\260\347\233\270\345\212\240 II.md" "b/Solutions/0454. \345\233\233\346\225\260\347\233\270\345\212\240 II.md"
index 1ea2dbb8..dee9d5b3 100644
--- "a/Solutions/0454. \345\233\233\346\225\260\347\233\270\345\212\240 II.md"
+++ "b/Solutions/0454. \345\233\233\346\225\260\347\233\270\345\212\240 II.md"
@@ -19,7 +19,7 @@
## 代码
-```Python
+```python
class Solution:
def fourSumCount(self, nums1: List[int], nums2: List[int], nums3: List[int], nums4: List[int]) -> int:
nums_dict = dict()
diff --git "a/Solutions/0455. \345\210\206\345\217\221\351\245\274\345\271\262.md" "b/Solutions/0455. \345\210\206\345\217\221\351\245\274\345\271\262.md"
index 5e116b5d..f2397b3c 100644
--- "a/Solutions/0455. \345\210\206\345\217\221\351\245\274\345\271\262.md"
+++ "b/Solutions/0455. \345\210\206\345\217\221\351\245\274\345\271\262.md"
@@ -21,7 +21,7 @@
- 示例 1:
-```Python
+```python
输入:g = [1,2,3], s = [1,1]
输出:1
解释:你有三个孩子和两块小饼干,3 个孩子的胃口值分别是:1, 2, 3。虽然你有两块小饼干,由于他们的尺寸都是 1,你只能让胃口值是 1 的孩子满足。所以应该输出 1。
@@ -29,7 +29,7 @@
- 示例 2:
-```Python
+```python
输入: g = [1,2], s = [1,2,3]
输出: 2
解释: 你有两个孩子和三块小饼干,2个孩子的胃口值分别是1, 2。你拥有的饼干数量和尺寸都足以让所有孩子满足。所以你应该输出 2。
@@ -59,7 +59,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def findContentChildren(self, g: List[int], s: List[int]) -> int:
g.sort()
diff --git "a/Solutions/0459. \351\207\215\345\244\215\347\232\204\345\255\220\345\255\227\347\254\246\344\270\262.md" "b/Solutions/0459. \351\207\215\345\244\215\347\232\204\345\255\220\345\255\227\347\254\246\344\270\262.md"
index 592b1bbb..dce76e3e 100644
--- "a/Solutions/0459. \351\207\215\345\244\215\347\232\204\345\255\220\345\255\227\347\254\246\344\270\262.md"
+++ "b/Solutions/0459. \351\207\215\345\244\215\347\232\204\345\255\220\345\255\227\347\254\246\344\270\262.md"
@@ -18,7 +18,7 @@
- 示例 1:
-```Python
+```python
输入: s = "abab"
输出: true
解释: 可由子串 "ab" 重复两次构成。
@@ -26,7 +26,7 @@
- 示例 2:
-```Python
+```python
输入: s = "aba"
输出: false
```
@@ -47,7 +47,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def generateNext(self, p: str):
m = len(p)
diff --git "a/Solutions/0461. \346\261\211\346\230\216\350\267\235\347\246\273.md" "b/Solutions/0461. \346\261\211\346\230\216\350\267\235\347\246\273.md"
index 23bdb91e..b66c9e42 100644
--- "a/Solutions/0461. \346\261\211\346\230\216\350\267\235\347\246\273.md"
+++ "b/Solutions/0461. \346\261\211\346\230\216\350\267\235\347\246\273.md"
@@ -22,7 +22,7 @@
## 代码
1. 逐位移动
-```Python
+```python
class Solution:
def hammingDistance(self, x: int, y: int) -> int:
xor = x ^ y
@@ -35,7 +35,7 @@ class Solution:
```
2. $n \text{ \& } (n - 1)$ 运算
-```Python
+```python
class Solution:
def hammingDistance(self, x: int, y: int) -> int:
xor = x ^ y
diff --git "a/Solutions/0463. \345\262\233\345\261\277\347\232\204\345\221\250\351\225\277.md" "b/Solutions/0463. \345\262\233\345\261\277\347\232\204\345\221\250\351\225\277.md"
index c43adf30..6ef3c04d 100644
--- "a/Solutions/0463. \345\262\233\345\261\277\347\232\204\345\221\250\351\225\277.md"
+++ "b/Solutions/0463. \345\262\233\345\261\277\347\232\204\345\221\250\351\225\277.md"
@@ -26,7 +26,7 @@

-```Python
+```python
输入:grid = [[0,1,0,0],[1,1,1,0],[0,1,0,0],[1,1,0,0]]
输出:16
解释:它的周长是上面图片中的 16 个黄色的边
@@ -34,7 +34,7 @@
- 示例 2:
-```Python
+```python
输入:grid = [[1]]
输出:4
```
@@ -53,7 +53,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def bfs(self, grid, rows, cols, row, col):
directs = [(0, 1), (0, -1), (1, 0), (-1, 0)]
diff --git "a/Solutions/0464. \346\210\221\350\203\275\350\265\242\345\220\227.md" "b/Solutions/0464. \346\210\221\350\203\275\350\265\242\345\220\227.md"
index 5ac4150d..7aef4439 100644
--- "a/Solutions/0464. \346\210\221\350\203\275\350\265\242\345\220\227.md"
+++ "b/Solutions/0464. \346\210\221\350\203\275\350\265\242\345\220\227.md"
@@ -18,7 +18,7 @@
- 示例 1:
-```Python
+```python
输入:maxChoosableInteger = 10, desiredTotal = 11
输出:False
解释:
@@ -31,7 +31,7 @@
- 示例 2:
-```Python
+```python
输入:maxChoosableInteger = 10, desiredTotal = 0
输出:True
```
@@ -63,7 +63,7 @@ $maxChoosableInteger$ 的区间范围是 $[1, 20]$,数据量不是很大,我
### 思路 1:代码
-```Python
+```python
class Solution:
def canIWin(self, maxChoosableInteger: int, desiredTotal: int) -> bool:
@cache
diff --git "a/Solutions/0467. \347\216\257\347\273\225\345\255\227\347\254\246\344\270\262\344\270\255\345\224\257\344\270\200\347\232\204\345\255\220\345\255\227\347\254\246\344\270\262.md" "b/Solutions/0467. \347\216\257\347\273\225\345\255\227\347\254\246\344\270\262\344\270\255\345\224\257\344\270\200\347\232\204\345\255\220\345\255\227\347\254\246\344\270\262.md"
index 905c10f1..d054977d 100644
--- "a/Solutions/0467. \347\216\257\347\273\225\345\255\227\347\254\246\344\270\262\344\270\255\345\224\257\344\270\200\347\232\204\345\255\220\345\255\227\347\254\246\344\270\262.md"
+++ "b/Solutions/0467. \347\216\257\347\273\225\345\255\227\347\254\246\344\270\262\344\270\255\345\224\257\344\270\200\347\232\204\345\255\220\345\255\227\347\254\246\344\270\262.md"
@@ -22,7 +22,7 @@
## 代码
-```Python
+```python
class Solution:
def findSubstringInWraproundString(self, p: str) -> int:
dp = collections.defaultdict(int)
diff --git "a/Solutions/0468. \351\252\214\350\257\201IP\345\234\260\345\235\200.md" "b/Solutions/0468. \351\252\214\350\257\201IP\345\234\260\345\235\200.md"
index 5b67fece..f9ca8b55 100644
--- "a/Solutions/0468. \351\252\214\350\257\201IP\345\234\260\345\235\200.md"
+++ "b/Solutions/0468. \351\252\214\350\257\201IP\345\234\260\345\235\200.md"
@@ -27,7 +27,7 @@
- 示例 1:
-```Python
+```python
输入:queryIP = "172.16.254.1"
输出:"IPv4"
解释:有效的 IPv4 地址,返回 "IPv4"
@@ -35,7 +35,7 @@
- 示例 2:
-```Python
+```python
输入:queryIP = "2001:0db8:85a3:0:0:8A2E:0370:7334"
输出:"IPv6"
解释:有效的 IPv6 地址,返回 "IPv6"
@@ -72,7 +72,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def validIPAddress(self, queryIP: str) -> str:
path = queryIP.split('.')
diff --git "a/Solutions/0473. \347\201\253\346\237\264\346\213\274\346\255\243\346\226\271\345\275\242.md" "b/Solutions/0473. \347\201\253\346\237\264\346\213\274\346\255\243\346\226\271\345\275\242.md"
index 8b3f24c8..3ab3ddb1 100644
--- "a/Solutions/0473. \347\201\253\346\237\264\346\213\274\346\255\243\346\226\271\345\275\242.md"
+++ "b/Solutions/0473. \347\201\253\346\237\264\346\213\274\346\255\243\346\226\271\345\275\242.md"
@@ -18,7 +18,7 @@
- 示例 1:
-```Python
+```python
输入: matchsticks = [1,1,2,2,2]
输出: True
解释: 能拼成一个边长为 2 的正方形,每边两根火柴。
@@ -26,7 +26,7 @@
- 示例 2:
-```Python
+```python
输入: matchsticks = [3,3,3,3,4]
输出: False
解释: 不能用所有火柴拼成一个正方形。
@@ -43,7 +43,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def dfs(self, index, sums, matchsticks, size, side_len):
if index == size:
diff --git "a/Solutions/0474. \344\270\200\345\222\214\351\233\266.md" "b/Solutions/0474. \344\270\200\345\222\214\351\233\266.md"
index 78909bc1..3fe15544 100644
--- "a/Solutions/0474. \344\270\200\345\222\214\351\233\266.md"
+++ "b/Solutions/0474. \344\270\200\345\222\214\351\233\266.md"
@@ -21,7 +21,7 @@
- 示例 1:
-```Python
+```python
输入:strs = ["10", "0001", "111001", "1", "0"], m = 5, n = 3
输出:4
解释:最多有 5 个 0 和 3 个 1 的最大子集是 {"10","0001","1","0"} ,因此答案是 4 。
@@ -30,7 +30,7 @@
- 示例 2:
-```Python
+```python
输入:strs = ["10", "0", "1"], m = 1, n = 1
输出:2
解释:最大的子集是 {"0", "1"} ,所以答案是 2。
@@ -71,7 +71,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def findMaxForm(self, strs: List[str], m: int, n: int) -> int:
dp = [[0 for _ in range(n + 1)] for _ in range(m + 1)]
diff --git "a/Solutions/0480. \346\273\221\345\212\250\347\252\227\345\217\243\344\270\255\344\275\215\346\225\260.md" "b/Solutions/0480. \346\273\221\345\212\250\347\252\227\345\217\243\344\270\255\344\275\215\346\225\260.md"
index 1df07723..d89ae6bc 100644
--- "a/Solutions/0480. \346\273\221\345\212\250\347\252\227\345\217\243\344\270\255\344\275\215\346\225\260.md"
+++ "b/Solutions/0480. \346\273\221\345\212\250\347\252\227\345\217\243\344\270\255\344\275\215\346\225\260.md"
@@ -55,7 +55,7 @@
## 代码
-```Python
+```python
import collections
import heapq
diff --git "a/Solutions/0485. \346\234\200\345\244\247\350\277\236\347\273\255 1 \347\232\204\344\270\252\346\225\260.md" "b/Solutions/0485. \346\234\200\345\244\247\350\277\236\347\273\255 1 \347\232\204\344\270\252\346\225\260.md"
index fa222b7c..6ce9fb5e 100644
--- "a/Solutions/0485. \346\234\200\345\244\247\350\277\236\347\273\255 1 \347\232\204\344\270\252\346\225\260.md"
+++ "b/Solutions/0485. \346\234\200\345\244\247\350\277\236\347\273\255 1 \347\232\204\344\270\252\346\225\260.md"
@@ -13,7 +13,7 @@
## 代码
-```Python
+```python
class Solution:
def findMaxConsecutiveOnes(self, nums: List[int]) -> int:
ans = 0
diff --git "a/Solutions/0486. \351\242\204\346\265\213\350\265\242\345\256\266.md" "b/Solutions/0486. \351\242\204\346\265\213\350\265\242\345\256\266.md"
index af2085c7..3b7d4ca5 100644
--- "a/Solutions/0486. \351\242\204\346\265\213\350\265\242\345\256\266.md"
+++ "b/Solutions/0486. \351\242\204\346\265\213\350\265\242\345\256\266.md"
@@ -22,7 +22,7 @@
- 示例 1:
-```Python
+```python
输入:nums = [1,5,2]
输出:False
解释:一开始,玩家 1 可以从 1 和 2 中进行选择。
@@ -33,7 +33,7 @@
- 示例 2:
-```Python
+```python
输入:nums = [1,5,233,7]
输出:True
解释:玩家 1 一开始选择 1 。然后玩家 2 必须从 5 和 7 中进行选择。无论玩家 2 选择了哪个,玩家 1 都可以选择 233 。
@@ -70,7 +70,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def PredictTheWinner(self, nums: List[int]) -> bool:
size = len(nums)
diff --git "a/Solutions/0487. \346\234\200\345\244\247\350\277\236\347\273\2551\347\232\204\344\270\252\346\225\260 II.md" "b/Solutions/0487. \346\234\200\345\244\247\350\277\236\347\273\2551\347\232\204\344\270\252\346\225\260 II.md"
index fc9744c7..53d2438a 100644
--- "a/Solutions/0487. \346\234\200\345\244\247\350\277\236\347\273\2551\347\232\204\344\270\252\346\225\260 II.md"
+++ "b/Solutions/0487. \346\234\200\345\244\247\350\277\236\347\273\2551\347\232\204\344\270\252\346\225\260 II.md"
@@ -25,7 +25,7 @@
## 代码
-```Python
+```python
class Solution:
def findMaxConsecutiveOnes(self, nums: List[int]) -> int:
left, right = 0, 0
diff --git "a/Solutions/0491. \351\200\222\345\242\236\345\255\220\345\272\217\345\210\227.md" "b/Solutions/0491. \351\200\222\345\242\236\345\255\220\345\272\217\345\210\227.md"
index 675a600e..ad9bee70 100644
--- "a/Solutions/0491. \351\200\222\345\242\236\345\255\220\345\272\217\345\210\227.md"
+++ "b/Solutions/0491. \351\200\222\345\242\236\345\255\220\345\272\217\345\210\227.md"
@@ -25,7 +25,7 @@
## 代码
-```Python
+```python
class Solution:
res = []
path = []
diff --git "a/Solutions/0494. \347\233\256\346\240\207\345\222\214.md" "b/Solutions/0494. \347\233\256\346\240\207\345\222\214.md"
index 26f678b0..b8c42663 100644
--- "a/Solutions/0494. \347\233\256\346\240\207\345\222\214.md"
+++ "b/Solutions/0494. \347\233\256\346\240\207\345\222\214.md"
@@ -20,7 +20,7 @@
- 示例 1:
-```Python
+```python
输入:nums = [1,1,1,1,1], target = 3
输出:5
解释:一共有 5 种方法让最终目标和为 3。
@@ -33,7 +33,7 @@
- 示例 2:
-```Python
+```python
输入:nums = [1], target = 1
输出:1
```
@@ -56,7 +56,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def findTargetSumWays(self, nums: List[int], target: int) -> int:
size = len(nums)
@@ -98,7 +98,7 @@ class Solution:
### 思路 2:代码
-```Python
+```python
class Solution:
def findTargetSumWays(self, nums: List[int], target: int) -> int:
size = len(nums)
@@ -157,7 +157,7 @@ class Solution:
### 思路 3:代码
-```Python
+```python
class Solution:
def findTargetSumWays(self, nums: List[int], target: int) -> int:
sum_nums = sum(nums)
diff --git "a/Solutions/0496. \344\270\213\344\270\200\344\270\252\346\233\264\345\244\247\345\205\203\347\264\240 I.md" "b/Solutions/0496. \344\270\213\344\270\200\344\270\252\346\233\264\345\244\247\345\205\203\347\264\240 I.md"
index d4478c1d..775d6efa 100644
--- "a/Solutions/0496. \344\270\213\344\270\200\344\270\252\346\233\264\345\244\247\345\205\203\347\264\240 I.md"
+++ "b/Solutions/0496. \344\270\213\344\270\200\344\270\252\346\233\264\345\244\247\345\205\203\347\264\240 I.md"
@@ -21,7 +21,7 @@
- 示例 1:
-```Python
+```python
输入:nums1 = [4,1,2], nums2 = [1,3,4,2].
输出:[-1,3,-1]
解释:nums1 中每个值的下一个更大元素如下所述:
@@ -32,7 +32,7 @@
- 示例 2:
-```Python
+```python
输入:nums1 = [2,4], nums2 = [1,2,3,4].
输出:[3,-1]
解释:nums1 中每个值的下一个更大元素如下所述:
@@ -62,7 +62,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def nextGreaterElement(self, nums1: List[int], nums2: List[int]) -> List[int]:
res = []
diff --git "a/Solutions/0498. \345\257\271\350\247\222\347\272\277\351\201\215\345\216\206.md" "b/Solutions/0498. \345\257\271\350\247\222\347\272\277\351\201\215\345\216\206.md"
index 93fcb7cb..bd425a3d 100644
--- "a/Solutions/0498. \345\257\271\350\247\222\347\272\277\351\201\215\345\216\206.md"
+++ "b/Solutions/0498. \345\257\271\350\247\222\347\272\277\351\201\215\345\216\206.md"
@@ -21,7 +21,7 @@
- 示例 1:
-```Python
+```python
输入:mat = [[1,2,3],[4,5,6],[7,8,9]]
输出:[1,2,4,7,5,3,6,8,9]
```
@@ -52,7 +52,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def findDiagonalOrder(self, mat: List[List[int]]) -> List[int]:
rows = len(mat)
diff --git "a/Solutions/0501. \344\272\214\345\217\211\346\220\234\347\264\242\346\240\221\344\270\255\347\232\204\344\274\227\346\225\260.md" "b/Solutions/0501. \344\272\214\345\217\211\346\220\234\347\264\242\346\240\221\344\270\255\347\232\204\344\274\227\346\225\260.md"
index 6d9ca286..7508b705 100644
--- "a/Solutions/0501. \344\272\214\345\217\211\346\220\234\347\264\242\346\240\221\344\270\255\347\232\204\344\274\227\346\225\260.md"
+++ "b/Solutions/0501. \344\272\214\345\217\211\346\220\234\347\264\242\346\240\221\344\270\255\347\232\204\344\274\227\346\225\260.md"
@@ -36,7 +36,7 @@
## 代码
-```Python
+```python
class Solution:
res = []
count = 0
diff --git "a/Solutions/0503. \344\270\213\344\270\200\344\270\252\346\233\264\345\244\247\345\205\203\347\264\240 II.md" "b/Solutions/0503. \344\270\213\344\270\200\344\270\252\346\233\264\345\244\247\345\205\203\347\264\240 II.md"
index 9c7ff60e..4e420c24 100644
--- "a/Solutions/0503. \344\270\213\344\270\200\344\270\252\346\233\264\345\244\247\345\205\203\347\264\240 II.md"
+++ "b/Solutions/0503. \344\270\213\344\270\200\344\270\252\346\233\264\345\244\247\345\205\203\347\264\240 II.md"
@@ -30,7 +30,7 @@
## 代码
-```Python
+```python
size = len(nums)
res = [-1 for _ in range(size)]
stack = []
diff --git "a/Solutions/0504. \344\270\203\350\277\233\345\210\266\346\225\260.md" "b/Solutions/0504. \344\270\203\350\277\233\345\210\266\346\225\260.md"
index 6d0b14c5..a80870fb 100644
--- "a/Solutions/0504. \344\270\203\350\277\233\345\210\266\346\225\260.md"
+++ "b/Solutions/0504. \344\270\203\350\277\233\345\210\266\346\225\260.md"
@@ -13,7 +13,7 @@
## 代码
-```Python
+```python
class Solution:
def convertToBase7(self, num: int) -> str:
if num == 0:
diff --git "a/Solutions/0506. \347\233\270\345\257\271\345\220\215\346\254\241.md" "b/Solutions/0506. \347\233\270\345\257\271\345\220\215\346\254\241.md"
index 44a75ba6..0a68a73c 100644
--- "a/Solutions/0506. \347\233\270\345\257\271\345\220\215\346\254\241.md"
+++ "b/Solutions/0506. \347\233\270\345\257\271\345\220\215\346\254\241.md"
@@ -20,7 +20,7 @@
- 示例 1:
-```Python
+```python
输入:score = [5,4,3,2,1]
输出:["Gold Medal","Silver Medal","Bronze Medal","4","5"]
解释:名次为 [1st, 2nd, 3rd, 4th, 5th] 。
@@ -28,7 +28,7 @@
- 示例 2:
-```Python
+```python
输入:score = [10,3,8,9,4]
输出:["Gold Medal","5","Bronze Medal","Silver Medal","4"]
解释:名次为 [1st, 5th, 3rd, 2nd, 4th] 。
@@ -43,7 +43,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def shellSort(self, arr):
size = len(arr)
diff --git "a/Solutions/0509. \346\226\220\346\263\242\351\202\243\345\245\221\346\225\260.md" "b/Solutions/0509. \346\226\220\346\263\242\351\202\243\345\245\221\346\225\260.md"
index 09eb5def..093e3255 100644
--- "a/Solutions/0509. \346\226\220\346\263\242\351\202\243\345\245\221\346\225\260.md"
+++ "b/Solutions/0509. \346\226\220\346\263\242\351\202\243\345\245\221\346\225\260.md"
@@ -20,7 +20,7 @@
- 示例 1:
-```Python
+```python
输入:n = 2
输出:1
解释:F(2) = F(1) + F(0) = 1 + 0 = 1
@@ -28,7 +28,7 @@
- 示例 2:
-```Python
+```python
输入:n = 3
输出:2
解释:F(3) = F(2) + F(1) = 1 + 1 = 2
@@ -51,7 +51,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def fib(self, n: int) -> int:
if n == 0:
@@ -90,7 +90,7 @@ class Solution:
### 思路 2:代码
-```Python
+```python
class Solution:
def fib(self, n: int) -> int:
if n <= 1:
diff --git "a/Solutions/0513. \346\211\276\346\240\221\345\267\246\344\270\213\350\247\222\347\232\204\345\200\274.md" "b/Solutions/0513. \346\211\276\346\240\221\345\267\246\344\270\213\350\247\222\347\232\204\345\200\274.md"
index b16cf537..18e46a61 100644
--- "a/Solutions/0513. \346\211\276\346\240\221\345\267\246\344\270\213\350\247\222\347\232\204\345\200\274.md"
+++ "b/Solutions/0513. \346\211\276\346\240\221\345\267\246\344\270\213\350\247\222\347\232\204\345\200\274.md"
@@ -19,7 +19,7 @@
- 示例 1:
-```Python
+```python
输入:[1,2,3,4,null,5,6,null,null,7]
输出:7
```
@@ -42,7 +42,7 @@
### 思路 1:层序遍历代码
-```Python
+```python
import collections
class Solution:
def findBottomLeftValue(self, root: TreeNode) -> int:
diff --git "a/Solutions/0515. \345\234\250\346\257\217\344\270\252\346\240\221\350\241\214\344\270\255\346\211\276\346\234\200\345\244\247\345\200\274.md" "b/Solutions/0515. \345\234\250\346\257\217\344\270\252\346\240\221\350\241\214\344\270\255\346\211\276\346\234\200\345\244\247\345\200\274.md"
index 97b10f63..54cc5d1a 100644
--- "a/Solutions/0515. \345\234\250\346\257\217\344\270\252\346\240\221\350\241\214\344\270\255\346\211\276\346\234\200\345\244\247\345\200\274.md"
+++ "b/Solutions/0515. \345\234\250\346\257\217\344\270\252\346\240\221\350\241\214\344\270\255\346\211\276\346\234\200\345\244\247\345\200\274.md"
@@ -15,7 +15,7 @@
## 代码
-```Python
+```python
```
diff --git "a/Solutions/0516. \346\234\200\351\225\277\345\233\236\346\226\207\345\255\220\345\272\217\345\210\227.md" "b/Solutions/0516. \346\234\200\351\225\277\345\233\236\346\226\207\345\255\220\345\272\217\345\210\227.md"
index 9dc0da8d..ef62c6eb 100644
--- "a/Solutions/0516. \346\234\200\351\225\277\345\233\236\346\226\207\345\255\220\345\272\217\345\210\227.md"
+++ "b/Solutions/0516. \346\234\200\351\225\277\345\233\236\346\226\207\345\255\220\345\272\217\345\210\227.md"
@@ -19,7 +19,7 @@
- 示例 1:
-```Python
+```python
输入:s = "bbbab"
输出:4
解释:一个可能的最长回文子序列为 "bbbb"。
@@ -27,7 +27,7 @@
- 示例 2:
-```Python
+```python
输入:s = "cbbd"
输出:2
解释:一个可能的最长回文子序列为 "bb"。
@@ -70,7 +70,7 @@ $dp[i][j] = \begin{cases} max \lbrace dp[i + 1][j - 1] + 2 \rbrace & s[i] = s[j]
### 思路 1:代码
-```Python
+```python
class Solution:
def longestPalindromeSubseq(self, s: str) -> int:
size = len(s)
diff --git "a/Solutions/0518. \351\233\266\351\222\261\345\205\221\346\215\242 II.md" "b/Solutions/0518. \351\233\266\351\222\261\345\205\221\346\215\242 II.md"
index 1ca54d2a..0a737f80 100644
--- "a/Solutions/0518. \351\233\266\351\222\261\345\205\221\346\215\242 II.md"
+++ "b/Solutions/0518. \351\233\266\351\222\261\345\205\221\346\215\242 II.md"
@@ -21,7 +21,7 @@
- 示例 1:
-```Python
+```python
输入:amount = 5, coins = [1, 2, 5]
输出:4
解释:有四种方式可以凑成总金额:
@@ -33,7 +33,7 @@
- 示例 2:
-```Python
+```python
输入:amount = 3, coins = [2]
输出:0
解释:只用面额 2 的硬币不能凑成总金额 3。
@@ -69,7 +69,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def change(self, amount: int, coins: List[int]) -> int:
diff --git "a/Solutions/0525. \350\277\236\347\273\255\346\225\260\347\273\204.md" "b/Solutions/0525. \350\277\236\347\273\255\346\225\260\347\273\204.md"
index 9aa2547d..6b35d6a1 100644
--- "a/Solutions/0525. \350\277\236\347\273\255\346\225\260\347\273\204.md"
+++ "b/Solutions/0525. \350\277\236\347\273\255\346\225\260\347\273\204.md"
@@ -44,7 +44,7 @@
## 代码
-```Python
+```python
class Solution:
def findMaxLength(self, nums: List[int]) -> int:
pre_dic = {0: -1}
diff --git "a/Solutions/0526. \344\274\230\347\276\216\347\232\204\346\216\222\345\210\227.md" "b/Solutions/0526. \344\274\230\347\276\216\347\232\204\346\216\222\345\210\227.md"
index 8a1bfb07..a7662347 100644
--- "a/Solutions/0526. \344\274\230\347\276\216\347\232\204\346\216\222\345\210\227.md"
+++ "b/Solutions/0526. \344\274\230\347\276\216\347\232\204\346\216\222\345\210\227.md"
@@ -21,7 +21,7 @@
- 示例 1:
-```Python
+```python
输入:n = 2
输出:2
解释:
@@ -35,7 +35,7 @@
- 示例 2:
-```Python
+```python
输入:n = 1
输出:1
```
@@ -52,7 +52,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def countArrangement(self, n: int) -> int:
ans = 0
@@ -124,7 +124,7 @@ class Solution:
### 思路 2:代码
-```Python
+```python
class Solution:
def countArrangement(self, n: int) -> int:
states = 1 << n
@@ -187,7 +187,7 @@ $dp[state]$ 的状态肯定是由前 $one\underline{}num - 1$ 个数字,且 $s
### 思路 3:代码
-```Python
+```python
class Solution:
def countArrangement(self, n: int) -> int:
states = 1 << n
diff --git "a/Solutions/0530. \344\272\214\345\217\211\346\220\234\347\264\242\346\240\221\347\232\204\346\234\200\345\260\217\347\273\235\345\257\271\345\267\256.md" "b/Solutions/0530. \344\272\214\345\217\211\346\220\234\347\264\242\346\240\221\347\232\204\346\234\200\345\260\217\347\273\235\345\257\271\345\267\256.md"
index 18f0d704..729c52cd 100644
--- "a/Solutions/0530. \344\272\214\345\217\211\346\220\234\347\264\242\346\240\221\347\232\204\346\234\200\345\260\217\347\273\235\345\257\271\345\267\256.md"
+++ "b/Solutions/0530. \344\272\214\345\217\211\346\220\234\347\264\242\346\240\221\347\232\204\346\234\200\345\260\217\347\273\235\345\257\271\345\267\256.md"
@@ -23,7 +23,7 @@
## 代码
-```Python
+```python
class Solution:
ans = 999
pre = 999
diff --git "a/Solutions/0538. \346\212\212\344\272\214\345\217\211\346\220\234\347\264\242\346\240\221\350\275\254\346\215\242\344\270\272\347\264\257\345\212\240\346\240\221.md" "b/Solutions/0538. \346\212\212\344\272\214\345\217\211\346\220\234\347\264\242\346\240\221\350\275\254\346\215\242\344\270\272\347\264\257\345\212\240\346\240\221.md"
index 2649f672..90e0cd93 100644
--- "a/Solutions/0538. \346\212\212\344\272\214\345\217\211\346\220\234\347\264\242\346\240\221\350\275\254\346\215\242\344\270\272\347\264\257\345\212\240\346\240\221.md"
+++ "b/Solutions/0538. \346\212\212\344\272\214\345\217\211\346\220\234\347\264\242\346\240\221\350\275\254\346\215\242\344\270\272\347\264\257\345\212\240\346\240\221.md"
@@ -25,7 +25,7 @@
## 代码
-```Python
+```python
class Solution:
pre = 0
def createBinaryTree(self, root: TreeNode):
diff --git "a/Solutions/0539. \346\234\200\345\260\217\346\227\266\351\227\264\345\267\256.md" "b/Solutions/0539. \346\234\200\345\260\217\346\227\266\351\227\264\345\267\256.md"
index 0c8baf8c..5a101c64 100644
--- "a/Solutions/0539. \346\234\200\345\260\217\346\227\266\351\227\264\345\267\256.md"
+++ "b/Solutions/0539. \346\234\200\345\260\217\346\227\266\351\227\264\345\267\256.md"
@@ -18,7 +18,7 @@
## 代码
-```Python
+```python
class Solution:
def changeTime(self, timePoint: str):
hours, minutes = timePoint.split(':')
diff --git "a/Solutions/0542. 01 \347\237\251\351\230\265.md" "b/Solutions/0542. 01 \347\237\251\351\230\265.md"
index b93af782..6b0ad43b 100644
--- "a/Solutions/0542. 01 \347\237\251\351\230\265.md"
+++ "b/Solutions/0542. 01 \347\237\251\351\230\265.md"
@@ -25,7 +25,7 @@

-```Python
+```python
输入:mat = [[0,0,0],[0,1,0],[0,0,0]]
输出:[[0,0,0],[0,1,0],[0,0,0]]
```
@@ -34,7 +34,7 @@

-```Python
+```python
输入:mat = [[0,0,0],[0,1,0],[1,1,1]]
输出:[[0,0,0],[0,1,0],[1,2,1]]
```
@@ -64,7 +64,7 @@
### 思路 1:代码
-```Python
+```python
import collections
class Solution:
diff --git "a/Solutions/0543. \344\272\214\345\217\211\346\240\221\347\232\204\347\233\264\345\276\204.md" "b/Solutions/0543. \344\272\214\345\217\211\346\240\221\347\232\204\347\233\264\345\276\204.md"
index 95a3355a..0cc99354 100644
--- "a/Solutions/0543. \344\272\214\345\217\211\346\240\221\347\232\204\347\233\264\345\276\204.md"
+++ "b/Solutions/0543. \344\272\214\345\217\211\346\240\221\347\232\204\347\233\264\345\276\204.md"
@@ -19,7 +19,7 @@
- 示例 1:
-```Python
+```python
给定二叉树:
1
/ \
@@ -62,7 +62,7 @@
### 思路 1:代码
-```Python
+```python
# Definition for a binary tree node.
# class TreeNode:
# def __init__(self, val=0, left=None, right=None):
diff --git "a/Solutions/0546. \347\247\273\351\231\244\347\233\222\345\255\220.md" "b/Solutions/0546. \347\247\273\351\231\244\347\233\222\345\255\220.md"
index 80fca81c..82cf3ed5 100644
--- "a/Solutions/0546. \347\247\273\351\231\244\347\233\222\345\255\220.md"
+++ "b/Solutions/0546. \347\247\273\351\231\244\347\233\222\345\255\220.md"
@@ -20,7 +20,7 @@
- 示例 1:
-```Python
+```python
输入:boxes = [1,3,2,2,2,3,4,3,1]
输出:23
解释:
@@ -33,7 +33,7 @@
- 示例 2:
-```Python
+```python
输入:boxes = [1,1,1]
输出:9
```
@@ -75,7 +75,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def removeBoxes(self, boxes: List[int]) -> int:
size = len(boxes)
diff --git "a/Solutions/0547. \347\234\201\344\273\275\346\225\260\351\207\217.md" "b/Solutions/0547. \347\234\201\344\273\275\346\225\260\351\207\217.md"
index 3245cd2c..8ce46be5 100644
--- "a/Solutions/0547. \347\234\201\344\273\275\346\225\260\351\207\217.md"
+++ "b/Solutions/0547. \347\234\201\344\273\275\346\225\260\351\207\217.md"
@@ -28,7 +28,7 @@

-```Python
+```python
输入:isConnected = [[1,1,0],[1,1,0],[0,0,1]]
输出:2
```
@@ -37,7 +37,7 @@

-```Python
+```python
输入:isConnected = [[1,0,0],[0,1,0],[0,0,1]]
输出:3
```
@@ -51,7 +51,7 @@
### 思路 1:代码
-```Python
+```python
class UnionFind:
def __init__(self, n): # 初始化
self.fa = [i for i in range(n)] # 每个元素的集合编号初始化为数组 fa 的下标索引
diff --git "a/Solutions/0557. \345\217\215\350\275\254\345\255\227\347\254\246\344\270\262\344\270\255\347\232\204\345\215\225\350\257\215 III.md" "b/Solutions/0557. \345\217\215\350\275\254\345\255\227\347\254\246\344\270\262\344\270\255\347\232\204\345\215\225\350\257\215 III.md"
index 85c6b6b2..1f7aea38 100644
--- "a/Solutions/0557. \345\217\215\350\275\254\345\255\227\347\254\246\344\270\262\344\270\255\347\232\204\345\215\225\350\257\215 III.md"
+++ "b/Solutions/0557. \345\217\215\350\275\254\345\255\227\347\254\246\344\270\262\344\270\255\347\232\204\345\215\225\350\257\215 III.md"
@@ -21,14 +21,14 @@
- 示例 1:
-```Python
+```python
输入:s = "Let's take LeetCode contest"
输出:"s'teL ekat edoCteeL tsetnoc"
```
- 示例 2:
-```Python
+```python
输入: s = "God Ding"
输出:"doG gniD"
```
@@ -45,7 +45,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def reverseWords(self, s: str) -> str:
return " ".join(word[::-1] for word in s.split(" "))
diff --git "a/Solutions/0560. \345\222\214\344\270\272 K \347\232\204\345\255\220\346\225\260\347\273\204.md" "b/Solutions/0560. \345\222\214\344\270\272 K \347\232\204\345\255\220\346\225\260\347\273\204.md"
index c12b4819..128a0cc8 100644
--- "a/Solutions/0560. \345\222\214\344\270\272 K \347\232\204\345\255\220\346\225\260\347\273\204.md"
+++ "b/Solutions/0560. \345\222\214\344\270\272 K \347\232\204\345\255\220\346\225\260\347\273\204.md"
@@ -15,7 +15,7 @@
先考虑暴力做法,外层两重循环,遍历所有连续子数组,然后最内层再计算一下子数组的和。部分代码如下:
-```Python
+```python
for i in range(len(nums)):
for j in range(i + 1):
sum = countSum(i, j)
@@ -44,7 +44,7 @@ for i in range(len(nums)):
## 代码
-```Python
+```python
class Solution:
def subarraySum(self, nums: List[int], k: int) -> int:
pre_dic = {0: 1}
diff --git "a/Solutions/0561. \346\225\260\347\273\204\346\213\206\345\210\206.md" "b/Solutions/0561. \346\225\260\347\273\204\346\213\206\345\210\206.md"
index 3dcad4bf..413e83b9 100644
--- "a/Solutions/0561. \346\225\260\347\273\204\346\213\206\345\210\206.md"
+++ "b/Solutions/0561. \346\225\260\347\273\204\346\213\206\345\210\206.md"
@@ -19,7 +19,7 @@
- 示例 1:
-```Python
+```python
输入:nums = [1,4,3,2]
输出:4
解释:所有可能的分法(忽略元素顺序)为:
@@ -30,7 +30,7 @@
```
- 示例 2:
-```Python
+```python
输入:nums = [6,2,6,5,1,2]
输出:9
解释:最优的分法为 (2, 1), (2, 5), (6, 6). min(2, 1) + min(2, 5) + min(6, 6) = 1 + 2 + 6 = 9
@@ -47,7 +47,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def arrayPairSum(self, nums: List[int]) -> int:
nums.sort()
diff --git "a/Solutions/0567. \345\255\227\347\254\246\344\270\262\347\232\204\346\216\222\345\210\227.md" "b/Solutions/0567. \345\255\227\347\254\246\344\270\262\347\232\204\346\216\222\345\210\227.md"
index e36b0afb..0f0ae7d5 100644
--- "a/Solutions/0567. \345\255\227\347\254\246\344\270\262\347\232\204\346\216\222\345\210\227.md"
+++ "b/Solutions/0567. \345\255\227\347\254\246\344\270\262\347\232\204\346\216\222\345\210\227.md"
@@ -26,7 +26,7 @@
## 代码
-```Python
+```python
import collections
class Solution:
diff --git "a/Solutions/0575. \345\210\206\347\263\226\346\236\234.md" "b/Solutions/0575. \345\210\206\347\263\226\346\236\234.md"
index 30cb2681..9327d624 100644
--- "a/Solutions/0575. \345\210\206\347\263\226\346\236\234.md"
+++ "b/Solutions/0575. \345\210\206\347\263\226\346\236\234.md"
@@ -19,7 +19,7 @@
## 代码
-```Python
+```python
class Solution:
def distributeCandies(self, candyType: List[int]) -> int:
candy_set = set(candyType)
diff --git "a/Solutions/0576. \345\207\272\347\225\214\347\232\204\350\267\257\345\276\204\346\225\260.md" "b/Solutions/0576. \345\207\272\347\225\214\347\232\204\350\267\257\345\276\204\346\225\260.md"
index f8ff84d9..9ab2e6c3 100644
--- "a/Solutions/0576. \345\207\272\347\225\214\347\232\204\350\267\257\345\276\204\346\225\260.md"
+++ "b/Solutions/0576. \345\207\272\347\225\214\347\232\204\350\267\257\345\276\204\346\225\260.md"
@@ -22,7 +22,7 @@
- 示例 1:
-```Python
+```python
输入:m = 2, n = 2, maxMove = 2, startRow = 0, startColumn = 0
输出:6
```
@@ -44,7 +44,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def findPaths(self, m: int, n: int, maxMove: int, startRow: int, startColumn: int) -> int:
directions = {(1, 0), (-1, 0), (0, 1), (0, -1)}
@@ -108,7 +108,7 @@ class Solution:
### 思路 2:动态规划代码
-```Python
+```python
class Solution:
def findPaths(self, m: int, n: int, maxMove: int, startRow: int, startColumn: int) -> int:
directions = {(1, 0), (-1, 0), (0, 1), (0, -1)}
diff --git "a/Solutions/0583. \344\270\244\344\270\252\345\255\227\347\254\246\344\270\262\347\232\204\345\210\240\351\231\244\346\223\215\344\275\234.md" "b/Solutions/0583. \344\270\244\344\270\252\345\255\227\347\254\246\344\270\262\347\232\204\345\210\240\351\231\244\346\223\215\344\275\234.md"
index 4411201f..ca6f3a48 100644
--- "a/Solutions/0583. \344\270\244\344\270\252\345\255\227\347\254\246\344\270\262\347\232\204\345\210\240\351\231\244\346\223\215\344\275\234.md"
+++ "b/Solutions/0583. \344\270\244\344\270\252\345\255\227\347\254\246\344\270\262\347\232\204\345\210\240\351\231\244\346\223\215\344\275\234.md"
@@ -30,7 +30,7 @@
## 代码
-```Python
+```python
class Solution:
def minDistance(self, word1: str, word2: str) -> int:
size1 = len(word1)
diff --git "a/Solutions/0589. N \345\217\211\346\240\221\347\232\204\345\211\215\345\272\217\351\201\215\345\216\206.md" "b/Solutions/0589. N \345\217\211\346\240\221\347\232\204\345\211\215\345\272\217\351\201\215\345\216\206.md"
index cbda1119..4fa13006 100644
--- "a/Solutions/0589. N \345\217\211\346\240\221\347\232\204\345\211\215\345\272\217\351\201\215\345\216\206.md"
+++ "b/Solutions/0589. N \345\217\211\346\240\221\347\232\204\345\211\215\345\272\217\351\201\215\345\216\206.md"
@@ -25,7 +25,7 @@
## 代码
-```Python
+```python
class Solution:
def preorder(self, root: 'Node') -> List[int]:
res = []
diff --git "a/Solutions/0590. N \345\217\211\346\240\221\347\232\204\345\220\216\345\272\217\351\201\215\345\216\206.md" "b/Solutions/0590. N \345\217\211\346\240\221\347\232\204\345\220\216\345\272\217\351\201\215\345\216\206.md"
index 3048b937..cb6d2415 100644
--- "a/Solutions/0590. N \345\217\211\346\240\221\347\232\204\345\220\216\345\272\217\351\201\215\345\216\206.md"
+++ "b/Solutions/0590. N \345\217\211\346\240\221\347\232\204\345\220\216\345\272\217\351\201\215\345\216\206.md"
@@ -27,7 +27,7 @@ N 叉树的后序遍历顺序为:子节点顺序递归遍历 -> 根节点。
## 代码
-```Python
+```python
class Solution:
def postorder(self, root: 'Node') -> List[int]:
res = []
diff --git "a/Solutions/0599. \344\270\244\344\270\252\345\210\227\350\241\250\347\232\204\346\234\200\345\260\217\347\264\242\345\274\225\346\200\273\345\222\214.md" "b/Solutions/0599. \344\270\244\344\270\252\345\210\227\350\241\250\347\232\204\346\234\200\345\260\217\347\264\242\345\274\225\346\200\273\345\222\214.md"
index 093a7a6e..f17cd76b 100644
--- "a/Solutions/0599. \344\270\244\344\270\252\345\210\227\350\241\250\347\232\204\346\234\200\345\260\217\347\264\242\345\274\225\346\200\273\345\222\214.md"
+++ "b/Solutions/0599. \344\270\244\344\270\252\345\210\227\350\241\250\347\232\204\346\234\200\345\260\217\347\264\242\345\274\225\346\200\273\345\222\214.md"
@@ -17,7 +17,7 @@ Andy 和 Doris 都有一个表示最喜欢餐厅的列表 list1、list2,每个
## 代码
-```Python
+```python
class Solution:
def findRestaurant(self, list1: List[str], list2: List[str]) -> List[str]:
list1_dict = dict()
diff --git "a/Solutions/0600. \344\270\215\345\220\253\350\277\236\347\273\2551\347\232\204\351\235\236\350\264\237\346\225\264\346\225\260.md" "b/Solutions/0600. \344\270\215\345\220\253\350\277\236\347\273\2551\347\232\204\351\235\236\350\264\237\346\225\264\346\225\260.md"
index 0b0fb25e..8e982082 100644
--- "a/Solutions/0600. \344\270\215\345\220\253\350\277\236\347\273\2551\347\232\204\351\235\236\350\264\237\346\225\264\346\225\260.md"
+++ "b/Solutions/0600. \344\270\215\345\220\253\350\277\236\347\273\2551\347\232\204\351\235\236\350\264\237\346\225\264\346\225\260.md"
@@ -17,7 +17,7 @@
- 示例 1:
-```Python
+```python
输入: n = 5
输出: 5
解释:
@@ -33,7 +33,7 @@
- 示例 2:
-```Python
+```python
输入: n = 1
输出: 2
```
@@ -67,7 +67,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def findIntegers(self, n: int) -> int:
# 将 n 的二进制转换为字符串 s
diff --git "a/Solutions/0611. \346\234\211\346\225\210\344\270\211\350\247\222\345\275\242\347\232\204\344\270\252\346\225\260.md" "b/Solutions/0611. \346\234\211\346\225\210\344\270\211\350\247\222\345\275\242\347\232\204\344\270\252\346\225\260.md"
index fc17b13e..9130eb48 100644
--- "a/Solutions/0611. \346\234\211\346\225\210\344\270\211\350\247\222\345\275\242\347\232\204\344\270\252\346\225\260.md"
+++ "b/Solutions/0611. \346\234\211\346\225\210\344\270\211\350\247\222\345\275\242\347\232\204\344\270\252\346\225\260.md"
@@ -26,7 +26,7 @@
## 代码
-```Python
+```python
class Solution:
def triangleNumber(self, nums: List[int]) -> int:
nums.sort()
diff --git "a/Solutions/0616. \347\273\231\345\255\227\347\254\246\344\270\262\346\267\273\345\212\240\345\212\240\347\262\227\346\240\207\347\255\276.md" "b/Solutions/0616. \347\273\231\345\255\227\347\254\246\344\270\262\346\267\273\345\212\240\345\212\240\347\262\227\346\240\207\347\255\276.md"
index e19c2309..a2a9b5c9 100644
--- "a/Solutions/0616. \347\273\231\345\255\227\347\254\246\344\270\262\346\267\273\345\212\240\345\212\240\347\262\227\346\240\207\347\255\276.md"
+++ "b/Solutions/0616. \347\273\231\345\255\227\347\254\246\344\270\262\346\267\273\345\212\240\345\212\240\347\262\227\346\240\207\347\255\276.md"
@@ -19,7 +19,7 @@
## 代码
-```Python
+```python
class Trie:
def __init__(self):
diff --git "a/Solutions/0617. \345\220\210\345\271\266\344\272\214\345\217\211\346\240\221.md" "b/Solutions/0617. \345\220\210\345\271\266\344\272\214\345\217\211\346\240\221.md"
index 86e901a1..6a038e28 100644
--- "a/Solutions/0617. \345\220\210\345\271\266\344\272\214\345\217\211\346\240\221.md"
+++ "b/Solutions/0617. \345\220\210\345\271\266\344\272\214\345\217\211\346\240\221.md"
@@ -18,7 +18,7 @@
## 代码
-```Python
+```python
class Solution:
def mergeTrees(self, root1: TreeNode, root2: TreeNode) -> TreeNode:
if not root1:
diff --git "a/Solutions/0621. \344\273\273\345\212\241\350\260\203\345\272\246\345\231\250.md" "b/Solutions/0621. \344\273\273\345\212\241\350\260\203\345\272\246\345\231\250.md"
index 7b50b459..73af9abe 100644
--- "a/Solutions/0621. \344\273\273\345\212\241\350\260\203\345\272\246\345\231\250.md"
+++ "b/Solutions/0621. \344\273\273\345\212\241\350\260\203\345\272\246\345\231\250.md"
@@ -29,7 +29,7 @@
## 代码
-```Python
+```python
class Solution:
def leastInterval(self, tasks: List[str], n: int) -> int:
# 记录每个任务出现的次数
diff --git "a/Solutions/0622. \350\256\276\350\256\241\345\276\252\347\216\257\351\230\237\345\210\227.md" "b/Solutions/0622. \350\256\276\350\256\241\345\276\252\347\216\257\351\230\237\345\210\227.md"
index 27e8f0ad..dae2d590 100644
--- "a/Solutions/0622. \350\256\276\350\256\241\345\276\252\347\216\257\351\230\237\345\210\227.md"
+++ "b/Solutions/0622. \350\256\276\350\256\241\345\276\252\347\216\257\351\230\237\345\210\227.md"
@@ -25,7 +25,7 @@
- 示例 1:
-```Python
+```python
MyCircularQueue circularQueue = new MyCircularQueue(3); // 设置长度为 3
circularQueue.enQueue(1); // 返回 true
circularQueue.enQueue(2); // 返回 true
@@ -68,7 +68,7 @@ circularQueue.Rear(); // 返回 4
### 思路 1:代码
-```Python
+```python
class MyCircularQueue:
def __init__(self, k: int):
diff --git "a/Solutions/0633. \345\271\263\346\226\271\346\225\260\344\271\213\345\222\214.md" "b/Solutions/0633. \345\271\263\346\226\271\346\225\260\344\271\213\345\222\214.md"
index 2bddc870..01f7954d 100644
--- "a/Solutions/0633. \345\271\263\346\226\271\346\225\260\344\271\213\345\222\214.md"
+++ "b/Solutions/0633. \345\271\263\346\226\271\346\225\260\344\271\213\345\222\214.md"
@@ -20,7 +20,7 @@
## 代码
-```Python
+```python
class Solution:
def judgeSquareSum(self, c: int) -> bool:
a, b = 0, int(c ** 0.5)
diff --git "a/Solutions/0639. \350\247\243\347\240\201\346\226\271\346\263\225 II.md" "b/Solutions/0639. \350\247\243\347\240\201\346\226\271\346\263\225 II.md"
index 1666c148..7ebd61e3 100644
--- "a/Solutions/0639. \350\247\243\347\240\201\346\226\271\346\263\225 II.md"
+++ "b/Solutions/0639. \350\247\243\347\240\201\346\226\271\346\263\225 II.md"
@@ -27,7 +27,7 @@
- `s` 只包含数字,并且可能包含前导零。
- 题目数据保证答案肯定是一个 `32` 位的整数。
-```Python
+```python
输入:s = "*"
输出:9
解释:这一条编码消息可以表示 "1"、"2"、"3"、"4"、"5"、"6"、"7"、"8" 或 "9" 中的任意一条。可以分别解码成字符串 "A"、"B"、"C"、"D"、"E"、"F"、"G"、"H" 和 "I" 。因此,"*" 总共有 9 种解码方法。
@@ -87,7 +87,7 @@
### 思路 1:动态规划代码
-```Python
+```python
class Solution:
def parse1(self, ch):
if ch == '*':
diff --git "a/Solutions/0642. \350\256\276\350\256\241\346\220\234\347\264\242\350\207\252\345\212\250\350\241\245\345\205\250\347\263\273\347\273\237.md" "b/Solutions/0642. \350\256\276\350\256\241\346\220\234\347\264\242\350\207\252\345\212\250\350\241\245\345\205\250\347\263\273\347\273\237.md"
index 88e11a03..cc64cafd 100644
--- "a/Solutions/0642. \350\256\276\350\256\241\346\220\234\347\264\242\350\207\252\345\212\250\350\241\245\345\205\250\347\263\273\347\273\237.md"
+++ "b/Solutions/0642. \350\256\276\350\256\241\346\220\234\347\264\242\350\207\252\345\212\250\350\241\245\345\205\250\347\263\273\347\273\237.md"
@@ -36,7 +36,7 @@
## 代码
-```Python
+```python
import heapq
class Trie:
diff --git "a/Solutions/0643. \345\255\220\346\225\260\347\273\204\346\234\200\345\244\247\345\271\263\345\235\207\346\225\260 I.md" "b/Solutions/0643. \345\255\220\346\225\260\347\273\204\346\234\200\345\244\247\345\271\263\345\235\207\346\225\260 I.md"
index 1ec9f048..d1cf20dd 100644
--- "a/Solutions/0643. \345\255\220\346\225\260\347\273\204\346\234\200\345\244\247\345\271\263\345\235\207\346\225\260 I.md"
+++ "b/Solutions/0643. \345\255\220\346\225\260\347\273\204\346\234\200\345\244\247\345\271\263\345\235\207\346\225\260 I.md"
@@ -24,7 +24,7 @@
## 代码
-```Python
+```python
class Solution:
def findMaxAverage(self, nums: List[int], k: int) -> float:
left = 0
diff --git "a/Solutions/0647. \345\233\236\346\226\207\345\255\220\344\270\262.md" "b/Solutions/0647. \345\233\236\346\226\207\345\255\220\344\270\262.md"
index 15a75301..b83ebd0b 100644
--- "a/Solutions/0647. \345\233\236\346\226\207\345\255\220\344\270\262.md"
+++ "b/Solutions/0647. \345\233\236\346\226\207\345\255\220\344\270\262.md"
@@ -31,7 +31,7 @@
## 代码
-```Python
+```python
class Solution:
def countSubstrings(self, s: str) -> int:
size = len(s)
diff --git "a/Solutions/0648. \345\215\225\350\257\215\346\233\277\346\215\242.md" "b/Solutions/0648. \345\215\225\350\257\215\346\233\277\346\215\242.md"
index 43aaa42d..ac1ed6fa 100644
--- "a/Solutions/0648. \345\215\225\350\257\215\346\233\277\346\215\242.md"
+++ "b/Solutions/0648. \345\215\225\350\257\215\346\233\277\346\215\242.md"
@@ -25,14 +25,14 @@
- 示例 1:
-```Python
+```python
输入:dictionary = ["cat","bat","rat"], sentence = "the cattle was rattled by the battery"
输出:"the cat was rat by the bat"
```
- 示例 2:
-```Python
+```python
输入:dictionary = ["a","b","c"], sentence = "aadsfasf absbs bbab cadsfafs"
输出:"a a b c"
```
@@ -47,7 +47,7 @@
### 思路 1:代码
-```Python
+```python
class Trie:
def __init__(self):
diff --git "a/Solutions/0650. \345\217\252\346\234\211\344\270\244\344\270\252\351\224\256\347\232\204\351\224\256\347\233\230.md" "b/Solutions/0650. \345\217\252\346\234\211\344\270\244\344\270\252\351\224\256\347\232\204\351\224\256\347\233\230.md"
index 57eec6d5..d3641158 100644
--- "a/Solutions/0650. \345\217\252\346\234\211\344\270\244\344\270\252\351\224\256\347\232\204\351\224\256\347\233\230.md"
+++ "b/Solutions/0650. \345\217\252\346\234\211\344\270\244\344\270\252\351\224\256\347\232\204\351\224\256\347\233\230.md"
@@ -22,7 +22,7 @@
- 示例 1:
-```Python
+```python
输入:3
输出:3
解释
@@ -34,7 +34,7 @@
- 示例 2:
-```Python
+```python
输入:n = 1
输出:0
```
@@ -72,7 +72,7 @@
### 思路 1:动态规划代码
-```Python
+```python
import math
class Solution:
diff --git "a/Solutions/0652. \345\257\273\346\211\276\351\207\215\345\244\215\347\232\204\345\255\220\346\240\221.md" "b/Solutions/0652. \345\257\273\346\211\276\351\207\215\345\244\215\347\232\204\345\255\220\346\240\221.md"
index 10db6f87..30e2f0ff 100644
--- "a/Solutions/0652. \345\257\273\346\211\276\351\207\215\345\244\215\347\232\204\345\255\220\346\240\221.md"
+++ "b/Solutions/0652. \345\257\273\346\211\276\351\207\215\345\244\215\347\232\204\345\255\220\346\240\221.md"
@@ -15,7 +15,7 @@
## 代码
-```Python
+```python
class Solution:
def findDuplicateSubtrees(self, root: TreeNode) -> List[TreeNode]:
tree_dict = dict()
diff --git "a/Solutions/0653. \344\270\244\346\225\260\344\271\213\345\222\214 IV - \350\276\223\345\205\245\344\272\214\345\217\211\346\220\234\347\264\242\346\240\221.md" "b/Solutions/0653. \344\270\244\346\225\260\344\271\213\345\222\214 IV - \350\276\223\345\205\245\344\272\214\345\217\211\346\220\234\347\264\242\346\240\221.md"
index 7b6f5be8..bdf2d17b 100644
--- "a/Solutions/0653. \344\270\244\346\225\260\344\271\213\345\222\214 IV - \350\276\223\345\205\245\344\272\214\345\217\211\346\220\234\347\264\242\346\240\221.md"
+++ "b/Solutions/0653. \344\270\244\346\225\260\344\271\213\345\222\214 IV - \350\276\223\345\205\245\344\272\214\345\217\211\346\220\234\347\264\242\346\240\221.md"
@@ -15,7 +15,7 @@
## 代码
-```Python
+```python
class Solution:
def inOrder(self, root, nums):
if not root:
diff --git "a/Solutions/0654. \346\234\200\345\244\247\344\272\214\345\217\211\346\240\221.md" "b/Solutions/0654. \346\234\200\345\244\247\344\272\214\345\217\211\346\240\221.md"
index b04ba423..0ece737f 100644
--- "a/Solutions/0654. \346\234\200\345\244\247\344\272\214\345\217\211\346\240\221.md"
+++ "b/Solutions/0654. \346\234\200\345\244\247\344\272\214\345\217\211\346\240\221.md"
@@ -23,7 +23,7 @@
## 代码
-```Python
+```python
class Solution:
def createBinaryTree(self, nums: List[int], left: int, right: int) -> TreeNode:
if left >= right:
diff --git "a/Solutions/0658. \346\211\276\345\210\260 K \344\270\252\346\234\200\346\216\245\350\277\221\347\232\204\345\205\203\347\264\240.md" "b/Solutions/0658. \346\211\276\345\210\260 K \344\270\252\346\234\200\346\216\245\350\277\221\347\232\204\345\205\203\347\264\240.md"
index 685b91e1..39afcba5 100644
--- "a/Solutions/0658. \346\211\276\345\210\260 K \344\270\252\346\234\200\346\216\245\350\277\221\347\232\204\345\205\203\347\264\240.md"
+++ "b/Solutions/0658. \346\211\276\345\210\260 K \344\270\252\346\234\200\346\216\245\350\277\221\347\232\204\345\205\203\347\264\240.md"
@@ -26,7 +26,7 @@
## 代码
-```Python
+```python
class Solution:
def findClosestElements(self, arr: List[int], k: int, x: int) -> List[int]:
n = len(arr)
diff --git "a/Solutions/0662. \344\272\214\345\217\211\346\240\221\346\234\200\345\244\247\345\256\275\345\272\246.md" "b/Solutions/0662. \344\272\214\345\217\211\346\240\221\346\234\200\345\244\247\345\256\275\345\272\246.md"
index 2678b96f..680711f1 100644
--- "a/Solutions/0662. \344\272\214\345\217\211\346\240\221\346\234\200\345\244\247\345\256\275\345\272\246.md"
+++ "b/Solutions/0662. \344\272\214\345\217\211\346\240\221\346\234\200\345\244\247\345\256\275\345\272\246.md"
@@ -23,7 +23,7 @@

-```Python
+```python
输入:root = [1,3,2,5,3,null,9]
输出:4
解释:最大宽度出现在树的第 3 层,宽度为 4 (5,3,null,9)。
@@ -33,7 +33,7 @@

-```Python
+```python
输入:root = [1,3,2,5,null,null,9,6,null,7]
输出:7
解释:最大宽度出现在树的第 4 层,宽度为 7 (6,null,null,null,null,null,7) 。
@@ -55,7 +55,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def widthOfBinaryTree(self, root: Optional[TreeNode]) -> int:
if not root:
diff --git "a/Solutions/0664. \345\245\207\346\200\252\347\232\204\346\211\223\345\215\260\346\234\272.md" "b/Solutions/0664. \345\245\207\346\200\252\347\232\204\346\211\223\345\215\260\346\234\272.md"
index 8c898ef7..86a5bdfc 100644
--- "a/Solutions/0664. \345\245\207\346\200\252\347\232\204\346\211\223\345\215\260\346\234\272.md"
+++ "b/Solutions/0664. \345\245\207\346\200\252\347\232\204\346\211\223\345\215\260\346\234\272.md"
@@ -23,7 +23,7 @@
- 示例 1:
-```Python
+```python
输入:s = "aaabbb"
输出:2
解释:首先打印 "aaa" 然后打印 "bbb"。
@@ -31,7 +31,7 @@
- 示例 2:
-```Python
+```python
输入:s = "aba"
输出:2
解释:首先打印 "aaa" 然后在第二个位置打印 "b" 覆盖掉原来的字符 'a'。
@@ -70,7 +70,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def strangePrinter(self, s: str) -> int:
size = len(s)
diff --git "a/Solutions/0665. \351\235\236\351\200\222\345\207\217\346\225\260\345\210\227.md" "b/Solutions/0665. \351\235\236\351\200\222\345\207\217\346\225\260\345\210\227.md"
index ee0cf79f..22977eee 100644
--- "a/Solutions/0665. \351\235\236\351\200\222\345\207\217\346\225\260\345\210\227.md"
+++ "b/Solutions/0665. \351\235\236\351\200\222\345\207\217\346\225\260\345\210\227.md"
@@ -24,7 +24,7 @@
## 代码
-```Python
+```python
class Solution:
def checkPossibility(self, nums: List[int]) -> bool:
count = 0
diff --git "a/Solutions/0669. \344\277\256\345\211\252\344\272\214\345\217\211\346\220\234\347\264\242\346\240\221.md" "b/Solutions/0669. \344\277\256\345\211\252\344\272\214\345\217\211\346\220\234\347\264\242\346\240\221.md"
index 882eb4f1..e3278f7b 100644
--- "a/Solutions/0669. \344\277\256\345\211\252\344\272\214\345\217\211\346\220\234\347\264\242\346\240\221.md"
+++ "b/Solutions/0669. \344\277\256\345\211\252\344\272\214\345\217\211\346\220\234\347\264\242\346\240\221.md"
@@ -20,7 +20,7 @@
## 代码
-```Python
+```python
class Solution:
def trimBST(self, root: TreeNode, low: int, high: int) -> TreeNode:
if not root:
diff --git "a/Solutions/0673. \346\234\200\351\225\277\351\200\222\345\242\236\345\255\220\345\272\217\345\210\227\347\232\204\344\270\252\346\225\260.md" "b/Solutions/0673. \346\234\200\351\225\277\351\200\222\345\242\236\345\255\220\345\272\217\345\210\227\347\232\204\344\270\252\346\225\260.md"
index 32dea694..e7e634f3 100644
--- "a/Solutions/0673. \346\234\200\351\225\277\351\200\222\345\242\236\345\255\220\345\272\217\345\210\227\347\232\204\344\270\252\346\225\260.md"
+++ "b/Solutions/0673. \346\234\200\351\225\277\351\200\222\345\242\236\345\255\220\345\272\217\345\210\227\347\232\204\344\270\252\346\225\260.md"
@@ -19,7 +19,7 @@
- 示例 1:
-```Python
+```python
输入:[1,3,5,4,7]
输出:2
解释:有两个最长递增子序列,分别是 [1, 3, 4, 7] 和[1, 3, 5, 7]。
@@ -53,7 +53,7 @@
### 思路 1:动态规划代码
-```Python
+```python
class Solution:
def findNumberOfLIS(self, nums: List[int]) -> int:
size = len(nums)
@@ -93,7 +93,7 @@ class Solution:
### 思路 2:线段树代码
-```Python
+```python
# 线段树的节点类
class SegTreeNode:
def __init__(self, val=[0, 1]):
diff --git "a/Solutions/0674. \346\234\200\351\225\277\350\277\236\347\273\255\351\200\222\345\242\236\345\272\217\345\210\227.md" "b/Solutions/0674. \346\234\200\351\225\277\350\277\236\347\273\255\351\200\222\345\242\236\345\272\217\345\210\227.md"
index a82e5533..3ce66df1 100644
--- "a/Solutions/0674. \346\234\200\351\225\277\350\277\236\347\273\255\351\200\222\345\242\236\345\272\217\345\210\227.md"
+++ "b/Solutions/0674. \346\234\200\351\225\277\350\277\236\347\273\255\351\200\222\345\242\236\345\272\217\345\210\227.md"
@@ -19,7 +19,7 @@
- 示例 1:
-```Python
+```python
输入:nums = [1,3,5,4,7]
输出:3
解释:最长连续递增序列是 [1,3,5], 长度为 3。尽管 [1,3,5,7] 也是升序的子序列, 但它不是连续的,因为 5 和 7 在原数组里被 4 隔开。
@@ -57,7 +57,7 @@
### 思路 1:动态规划代码
-```Python
+```python
class Solution:
def findLengthOfLCIS(self, nums: List[int]) -> int:
size = len(nums)
@@ -88,7 +88,7 @@ class Solution:
### 思路 2:代码
-```Python
+```python
class Solution:
def findLengthOfLCIS(self, nums: List[int]) -> int:
size = len(nums)
diff --git "a/Solutions/0676. \345\256\236\347\216\260\344\270\200\344\270\252\351\255\224\346\263\225\345\255\227\345\205\270.md" "b/Solutions/0676. \345\256\236\347\216\260\344\270\200\344\270\252\351\255\224\346\263\225\345\255\227\345\205\270.md"
index cafa362d..560f7c0a 100644
--- "a/Solutions/0676. \345\256\236\347\216\260\344\270\200\344\270\252\351\255\224\346\263\225\345\255\227\345\205\270.md"
+++ "b/Solutions/0676. \345\256\236\347\216\260\344\270\200\344\270\252\351\255\224\346\263\225\345\255\227\345\205\270.md"
@@ -28,7 +28,7 @@
- 示例 1:
-```Python
+```python
输入
["MagicDictionary", "buildDict", "search", "search", "search", "search"]
[[], [["hello", "leetcode"]], ["hello"], ["hhllo"], ["hell"], ["leetcoded"]]
@@ -54,7 +54,7 @@ magicDictionary.search("leetcoded"); // 返回 False
### 思路 1:代码
-```Python
+```python
class Trie:
def __init__(self):
diff --git "a/Solutions/0677. \351\224\256\345\200\274\346\230\240\345\260\204.md" "b/Solutions/0677. \351\224\256\345\200\274\346\230\240\345\260\204.md"
index 122831d0..acca4c9d 100644
--- "a/Solutions/0677. \351\224\256\345\200\274\346\230\240\345\260\204.md"
+++ "b/Solutions/0677. \351\224\256\345\200\274\346\230\240\345\260\204.md"
@@ -22,7 +22,7 @@
- 示例 1:
-```Python
+```python
输入:
["MapSum", "insert", "sum", "insert", "sum"]
[[], ["apple", 3], ["ap"], ["app", 2], ["ap"]]
@@ -50,7 +50,7 @@ mapSum.sum("ap"); // 返回 5 (apple + app = 3 + 2 = 5)
### 思路 1:代码
-```Python
+```python
class Trie:
def __init__(self):
diff --git "a/Solutions/0678. \346\234\211\346\225\210\347\232\204\346\213\254\345\217\267\345\255\227\347\254\246\344\270\262.md" "b/Solutions/0678. \346\234\211\346\225\210\347\232\204\346\213\254\345\217\267\345\255\227\347\254\246\344\270\262.md"
index 8d70b64d..1be9cb0e 100644
--- "a/Solutions/0678. \346\234\211\346\225\210\347\232\204\346\213\254\345\217\267\345\255\227\347\254\246\344\270\262.md"
+++ "b/Solutions/0678. \346\234\211\346\225\210\347\232\204\346\213\254\345\217\267\345\255\227\347\254\246\344\270\262.md"
@@ -23,7 +23,7 @@
- 示例 1:
-```Python
+```python
输入:"(*)"
输出:True
```
@@ -58,7 +58,7 @@
### 思路 1:动态规划(时间复杂度为 $O(n^3)$)代码
-```Python
+```python
class Solution:
def checkValidString(self, s: str) -> bool:
size = len(s)
@@ -115,7 +115,7 @@ class Solution:
### 思路 2:动态规划(时间复杂度为 $O(n^2)$)代码
-```Python
+```python
class Solution:
def checkValidString(self, s: str) -> bool:
size = len(s)
diff --git "a/Solutions/0680. \351\252\214\350\257\201\345\233\236\346\226\207\344\270\262 II.md" "b/Solutions/0680. \351\252\214\350\257\201\345\233\236\346\226\207\344\270\262 II.md"
index 01163645..322b623c 100644
--- "a/Solutions/0680. \351\252\214\350\257\201\345\233\236\346\226\207\344\270\262 II.md"
+++ "b/Solutions/0680. \351\252\214\350\257\201\345\233\236\346\226\207\344\270\262 II.md"
@@ -26,7 +26,7 @@
## 代码
-```Python
+```python
class Solution:
def checkPalindrome(self, s: str, left: int, right: int):
i, j = left, right
diff --git "a/Solutions/0683. K \344\270\252\345\205\263\351\227\255\347\232\204\347\201\257\346\263\241.md" "b/Solutions/0683. K \344\270\252\345\205\263\351\227\255\347\232\204\347\201\257\346\263\241.md"
index b29d5085..fd3acc74 100644
--- "a/Solutions/0683. K \344\270\252\345\205\263\351\227\255\347\232\204\347\201\257\346\263\241.md"
+++ "b/Solutions/0683. K \344\270\252\345\205\263\351\227\255\347\232\204\347\201\257\346\263\241.md"
@@ -26,7 +26,7 @@
## 代码
-```Python
+```python
class Solution:
def kEmptySlots(self, bulbs: List[int], k: int) -> int:
size = len(bulbs)
diff --git "a/Solutions/0684. \345\206\227\344\275\231\350\277\236\346\216\245.md" "b/Solutions/0684. \345\206\227\344\275\231\350\277\236\346\216\245.md"
index 437cbe16..06987762 100644
--- "a/Solutions/0684. \345\206\227\344\275\231\350\277\236\346\216\245.md"
+++ "b/Solutions/0684. \345\206\227\344\275\231\350\277\236\346\216\245.md"
@@ -27,7 +27,7 @@

-```Python
+```python
输入: edges = [[1,2], [1,3], [2,3]]
输出: [2,3]
```
@@ -36,7 +36,7 @@

-```Python
+```python
输入: edges = [[1,2], [2,3], [3,4], [1,4], [1,5]]
输出: [1,4]
```
@@ -53,7 +53,7 @@
### 思路 1:代码
-```Python
+```python
class UnionFind:
def __init__(self, n):
diff --git "a/Solutions/0686. \351\207\215\345\244\215\345\217\240\345\212\240\345\255\227\347\254\246\344\270\262\345\214\271\351\205\215.md" "b/Solutions/0686. \351\207\215\345\244\215\345\217\240\345\212\240\345\255\227\347\254\246\344\270\262\345\214\271\351\205\215.md"
index de9cec26..07c06506 100644
--- "a/Solutions/0686. \351\207\215\345\244\215\345\217\240\345\212\240\345\255\227\347\254\246\344\270\262\345\214\271\351\205\215.md"
+++ "b/Solutions/0686. \351\207\215\345\244\215\345\217\240\345\212\240\345\255\227\347\254\246\344\270\262\345\214\271\351\205\215.md"
@@ -20,7 +20,7 @@
- 示例 1:
-```Python
+```python
输入:a = "abcd", b = "cdabcdab"
输出:3
解释:a 重复叠加三遍后为 "abcdabcdabcd", 此时 b 是其子串。
@@ -28,7 +28,7 @@
- 示例 2:
-```Python
+```python
输入:a = "a", b = "aa"
输出:2
```
@@ -62,7 +62,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
# KMP 匹配算法,T 为文本串,p 为模式串
def kmp(self, T: str, p: str) -> int:
diff --git "a/Solutions/0687. \346\234\200\351\225\277\345\220\214\345\200\274\350\267\257\345\276\204.md" "b/Solutions/0687. \346\234\200\351\225\277\345\220\214\345\200\274\350\267\257\345\276\204.md"
index 1d32c951..fb238f77 100644
--- "a/Solutions/0687. \346\234\200\351\225\277\345\220\214\345\200\274\350\267\257\345\276\204.md"
+++ "b/Solutions/0687. \346\234\200\351\225\277\345\220\214\345\200\274\350\267\257\345\276\204.md"
@@ -22,7 +22,7 @@

-```Python
+```python
输入:root = [5,4,5,1,1,5]
输出:2
```
@@ -31,7 +31,7 @@

-```Python
+```python
输入:root = [1,4,5,4,4,5]
输出:2
```
@@ -75,7 +75,7 @@
### 思路 1:代码
-```Python
+```python
# Definition for a binary tree node.
# class TreeNode:
# def __init__(self, val=0, left=None, right=None):
diff --git "a/Solutions/0688. \351\252\221\345\243\253\345\234\250\346\243\213\347\233\230\344\270\212\347\232\204\346\246\202\347\216\207.md" "b/Solutions/0688. \351\252\221\345\243\253\345\234\250\346\243\213\347\233\230\344\270\212\347\232\204\346\246\202\347\216\207.md"
index 1148ef0a..6c9f331a 100644
--- "a/Solutions/0688. \351\252\221\345\243\253\345\234\250\346\243\213\347\233\230\344\270\212\347\232\204\346\246\202\347\216\207.md"
+++ "b/Solutions/0688. \351\252\221\345\243\253\345\234\250\346\243\213\347\233\230\344\270\212\347\232\204\346\246\202\347\216\207.md"
@@ -27,7 +27,7 @@
- 示例 1:
-```Python
+```python
输入:n = 3, k = 2, row = 0, column = 0
输出:0.0625
解释:有两步(到(1,2),(2,1))可以让骑士留在棋盘上。在每一个位置上,也有两种移动可以让骑士留在棋盘上。骑士留在棋盘上的总概率是 0.0625。
@@ -64,7 +64,7 @@
### 思路 1:动态规划代码
-```Python
+```python
class Solution:
def knightProbability(self, n: int, k: int, row: int, column: int) -> float:
dp = [[[0 for _ in range(k + 1)] for _ in range(n)] for _ in range(n)]
diff --git "a/Solutions/0690. \345\221\230\345\267\245\347\232\204\351\207\215\350\246\201\346\200\247.md" "b/Solutions/0690. \345\221\230\345\267\245\347\232\204\351\207\215\350\246\201\346\200\247.md"
index 000ae4e1..2b32105d 100644
--- "a/Solutions/0690. \345\221\230\345\267\245\347\232\204\351\207\215\350\246\201\346\200\247.md"
+++ "b/Solutions/0690. \345\221\230\345\267\245\347\232\204\351\207\215\350\246\201\346\200\247.md"
@@ -15,7 +15,7 @@
## 代码
-```Python
+```python
class Solution:
def getImportance(self, employees: List['Employee'], id: int) -> int:
employee_dict = dict()
diff --git "a/Solutions/0691. \350\264\264\347\272\270\346\213\274\350\257\215.md" "b/Solutions/0691. \350\264\264\347\272\270\346\213\274\350\257\215.md"
index 68a1a10c..2d7c3aee 100644
--- "a/Solutions/0691. \350\264\264\347\272\270\346\213\274\350\257\215.md"
+++ "b/Solutions/0691. \350\264\264\347\272\270\346\213\274\350\257\215.md"
@@ -22,7 +22,7 @@
- 示例 1:
-```Python
+```python
输入:stickers = ["with","example","science"], target = "thehat"
输出:3
解释:
@@ -33,7 +33,7 @@
- 示例 2:
-```Python
+```python
输入:stickers = ["notice","possible"], target = "basicbasic"
输出:-1
解释:我们不能通过剪切给定贴纸的字母来形成目标“basicbasic”。
@@ -61,7 +61,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def minStickers(self, stickers: List[str], target: str) -> int:
size = len(target)
diff --git "a/Solutions/0695. \345\262\233\345\261\277\347\232\204\346\234\200\345\244\247\351\235\242\347\247\257.md" "b/Solutions/0695. \345\262\233\345\261\277\347\232\204\346\234\200\345\244\247\351\235\242\347\247\257.md"
index a9730e16..a7b8625e 100644
--- "a/Solutions/0695. \345\262\233\345\261\277\347\232\204\346\234\200\345\244\247\351\235\242\347\247\257.md"
+++ "b/Solutions/0695. \345\262\233\345\261\277\347\232\204\346\234\200\345\244\247\351\235\242\347\247\257.md"
@@ -22,7 +22,7 @@

-```Python
+```python
输入:grid = [[0,0,1,0,0,0,0,1,0,0,0,0,0],[0,0,0,0,0,0,0,1,1,1,0,0,0],[0,1,1,0,1,0,0,0,0,0,0,0,0],[0,1,0,0,1,1,0,0,1,0,1,0,0],[0,1,0,0,1,1,0,0,1,1,1,0,0],[0,0,0,0,0,0,0,0,0,0,1,0,0],[0,0,0,0,0,0,0,1,1,1,0,0,0],[0,0,0,0,0,0,0,1,1,0,0,0,0]]
输出:6
解释:答案不应该是 11 ,因为岛屿只能包含水平或垂直这四个方向上的 1 。
@@ -30,7 +30,7 @@
- 示例 2:
-```Python
+```python
输入:grid = [[0,0,0,0,0,0,0,0]]
输出:0
```
@@ -48,7 +48,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def dfs(self, grid, i, j):
n = len(grid)
@@ -88,7 +88,7 @@ class Solution:
### 思路 2:代码
-```Python
+```python
import collections
class Solution:
diff --git "a/Solutions/0698. \345\210\222\345\210\206\344\270\272k\344\270\252\347\233\270\347\255\211\347\232\204\345\255\220\351\233\206.md" "b/Solutions/0698. \345\210\222\345\210\206\344\270\272k\344\270\252\347\233\270\347\255\211\347\232\204\345\255\220\351\233\206.md"
index 380ffe33..3d3569a6 100644
--- "a/Solutions/0698. \345\210\222\345\210\206\344\270\272k\344\270\252\347\233\270\347\255\211\347\232\204\345\255\220\351\233\206.md"
+++ "b/Solutions/0698. \345\210\222\345\210\206\344\270\272k\344\270\252\347\233\270\347\255\211\347\232\204\345\255\220\351\233\206.md"
@@ -19,7 +19,7 @@
- 示例 1:
-```Python
+```python
输入: nums = [4, 3, 2, 3, 5, 2, 1], k = 4
输出: True
说明: 有可能将其分成 4 个子集(5),(1,4),(2,3),(2,3)等于总和。
@@ -27,7 +27,7 @@
- 示例 2:
-```Python
+```python
输入: nums = [1,2,3,4], k = 3
输出: False
```
@@ -79,7 +79,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def canPartitionKSubsets(self, nums: List[int], k: int) -> bool:
size = len(nums)
diff --git "a/Solutions/0700. \344\272\214\345\217\211\346\220\234\347\264\242\346\240\221\344\270\255\347\232\204\346\220\234\347\264\242.md" "b/Solutions/0700. \344\272\214\345\217\211\346\220\234\347\264\242\346\240\221\344\270\255\347\232\204\346\220\234\347\264\242.md"
index 0f93643b..e9674346 100644
--- "a/Solutions/0700. \344\272\214\345\217\211\346\220\234\347\264\242\346\240\221\344\270\255\347\232\204\346\220\234\347\264\242.md"
+++ "b/Solutions/0700. \344\272\214\345\217\211\346\220\234\347\264\242\346\240\221\344\270\255\347\232\204\346\220\234\347\264\242.md"
@@ -22,7 +22,7 @@

-```Python
+```python
输入:root = [4,2,7,1,3], val = 2
输出:[2,1,3]
```
@@ -31,7 +31,7 @@

-```Python
+```python
输入:root = [4,2,7,1,3], val = 5
输出:[]
```
@@ -48,7 +48,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def searchBST(self, root: TreeNode, val: int) -> TreeNode:
if not root or val == root.val:
diff --git "a/Solutions/0701. \344\272\214\345\217\211\346\220\234\347\264\242\346\240\221\344\270\255\347\232\204\346\217\222\345\205\245\346\223\215\344\275\234.md" "b/Solutions/0701. \344\272\214\345\217\211\346\220\234\347\264\242\346\240\221\344\270\255\347\232\204\346\217\222\345\205\245\346\223\215\344\275\234.md"
index df24df75..bc147561 100644
--- "a/Solutions/0701. \344\272\214\345\217\211\346\220\234\347\264\242\346\240\221\344\270\255\347\232\204\346\217\222\345\205\245\346\223\215\344\275\234.md"
+++ "b/Solutions/0701. \344\272\214\345\217\211\346\220\234\347\264\242\346\240\221\344\270\255\347\232\204\346\217\222\345\205\245\346\223\215\344\275\234.md"
@@ -21,7 +21,7 @@
- 示例 1:
-```Python
+```python
输入:root = [4,2,7,1,3], val = 5
输出:[4,2,7,1,3,5]
解释:另一个满足题目要求可以通过的树是:
@@ -29,7 +29,7 @@
- 示例 2:
-```Python
+```python
输入:root = [40,20,60,10,30,50,70], val = 25
输出:[40,20,60,10,30,50,70,null,null,25]
```
@@ -56,7 +56,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def insertIntoBST(self, root: TreeNode, val: int) -> TreeNode:
if not root:
diff --git "a/Solutions/0702. \346\220\234\347\264\242\351\225\277\345\272\246\346\234\252\347\237\245\347\232\204\346\234\211\345\272\217\346\225\260\347\273\204.md" "b/Solutions/0702. \346\220\234\347\264\242\351\225\277\345\272\246\346\234\252\347\237\245\347\232\204\346\234\211\345\272\217\346\225\260\347\273\204.md"
index 4c2ab8ef..10ad0626 100644
--- "a/Solutions/0702. \346\220\234\347\264\242\351\225\277\345\272\246\346\234\252\347\237\245\347\232\204\346\234\211\345\272\217\346\225\260\347\273\204.md"
+++ "b/Solutions/0702. \346\220\234\347\264\242\351\225\277\345\272\246\346\234\252\347\237\245\347\232\204\346\234\211\345\272\217\346\225\260\347\273\204.md"
@@ -13,7 +13,7 @@
## 代码
-```Python
+```python
class Solution:
def binarySearch(self, reader, left, right, target):
while left < right:
diff --git "a/Solutions/0703. \346\225\260\346\215\256\346\265\201\344\270\255\347\232\204\347\254\254 K \345\244\247\345\205\203\347\264\240.md" "b/Solutions/0703. \346\225\260\346\215\256\346\265\201\344\270\255\347\232\204\347\254\254 K \345\244\247\345\205\203\347\264\240.md"
index 918a4a44..e41e37da 100644
--- "a/Solutions/0703. \346\225\260\346\215\256\346\265\201\344\270\255\347\232\204\347\254\254 K \345\244\247\345\205\203\347\264\240.md"
+++ "b/Solutions/0703. \346\225\260\346\215\256\346\265\201\344\270\255\347\232\204\347\254\254 K \345\244\247\345\205\203\347\264\240.md"
@@ -18,7 +18,7 @@
## 代码
-```Python
+```python
import heapq
class KthLargest:
diff --git "a/Solutions/0704. \344\272\214\345\210\206\346\237\245\346\211\276.md" "b/Solutions/0704. \344\272\214\345\210\206\346\237\245\346\211\276.md"
index f948e7e4..fece1559 100644
--- "a/Solutions/0704. \344\272\214\345\210\206\346\237\245\346\211\276.md"
+++ "b/Solutions/0704. \344\272\214\345\210\206\346\237\245\346\211\276.md"
@@ -19,7 +19,7 @@
- 示例 1:
-```Python
+```python
输入: nums = [-1,0,3,5,9,12], target = 9
输出: 4
解释: 9 出现在 nums 中并且下标为 4
@@ -27,7 +27,7 @@
- 示例 2:
-```Python
+```python
输入: nums = [-1,0,3,5,9,12], target = 2
输出: -1
解释: 2 不存在 nums 中因此返回 -1
@@ -48,7 +48,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def search(self, nums: List[int], target: int) -> int:
left, right = 0, len(nums) - 1
diff --git "a/Solutions/0705. \350\256\276\350\256\241\345\223\210\345\270\214\351\233\206\345\220\210.md" "b/Solutions/0705. \350\256\276\350\256\241\345\223\210\345\270\214\351\233\206\345\220\210.md"
index 98f0320f..b0aa8c9c 100644
--- "a/Solutions/0705. \350\256\276\350\256\241\345\223\210\345\270\214\351\233\206\345\220\210.md"
+++ "b/Solutions/0705. \350\256\276\350\256\241\345\223\210\345\270\214\351\233\206\345\220\210.md"
@@ -21,7 +21,7 @@
## 代码
-```Python
+```python
class MyHashSet:
def __init__(self):
diff --git "a/Solutions/0706. \350\256\276\350\256\241\345\223\210\345\270\214\346\230\240\345\260\204.md" "b/Solutions/0706. \350\256\276\350\256\241\345\223\210\345\270\214\346\230\240\345\260\204.md"
index d6538019..4665b1cf 100644
--- "a/Solutions/0706. \350\256\276\350\256\241\345\223\210\345\270\214\346\230\240\345\260\204.md"
+++ "b/Solutions/0706. \350\256\276\350\256\241\345\223\210\345\270\214\346\230\240\345\260\204.md"
@@ -23,7 +23,7 @@
- 示例 1:
-```Python
+```python
输入:
["MyHashMap", "put", "put", "get", "get", "put", "get", "remove", "get"]
[[], [1, 1], [2, 2], [1], [3], [2, 1], [2], [2], [2]]
@@ -61,7 +61,7 @@ myHashMap.get(2); // 返回 -1(未找到),myHashMap 现在为 [[1,1]]
### 思路 1:代码
-```Python
+```python
class MyHashMap:
def __init__(self):
diff --git "a/Solutions/0707. \350\256\276\350\256\241\351\223\276\350\241\250.md" "b/Solutions/0707. \350\256\276\350\256\241\351\223\276\350\241\250.md"
index 080fb2a3..50973c2c 100644
--- "a/Solutions/0707. \350\256\276\350\256\241\351\223\276\350\241\250.md"
+++ "b/Solutions/0707. \350\256\276\350\256\241\351\223\276\350\241\250.md"
@@ -23,7 +23,7 @@
- 示例 1:
-```Python
+```python
MyLinkedList linkedList = new MyLinkedList();
linkedList.addAtHead(1);
linkedList.addAtTail(3);
@@ -41,7 +41,7 @@ linkedList.get(1); // 返回 3
### 思路 1:代码
-```Python
+```python
class ListNode:
def __init__(self, x):
self.val = x
@@ -134,7 +134,7 @@ class MyLinkedList:
### 思路 2:代码
-```Python
+```python
class ListNode:
def __init__(self, x):
self.val = x
diff --git "a/Solutions/0708. \345\276\252\347\216\257\346\234\211\345\272\217\345\210\227\350\241\250\347\232\204\346\217\222\345\205\245.md" "b/Solutions/0708. \345\276\252\347\216\257\346\234\211\345\272\217\345\210\227\350\241\250\347\232\204\346\217\222\345\205\245.md"
index e09bda74..58c35e17 100644
--- "a/Solutions/0708. \345\276\252\347\216\257\346\234\211\345\272\217\345\210\227\350\241\250\347\232\204\346\217\222\345\205\245.md"
+++ "b/Solutions/0708. \345\276\252\347\216\257\346\234\211\345\272\217\345\210\227\350\241\250\347\232\204\346\217\222\345\205\245.md"
@@ -22,7 +22,7 @@
## 代码
-```Python
+```python
class Solution:
def insert(self, head: 'Node', insertVal: int) -> 'Node':
if not head:
diff --git "a/Solutions/0709. \350\275\254\346\215\242\346\210\220\345\260\217\345\206\231\345\255\227\346\257\215.md" "b/Solutions/0709. \350\275\254\346\215\242\346\210\220\345\260\217\345\206\231\345\255\227\346\257\215.md"
index 8c410330..338e66c0 100644
--- "a/Solutions/0709. \350\275\254\346\215\242\346\210\220\345\260\217\345\206\231\345\255\227\346\257\215.md"
+++ "b/Solutions/0709. \350\275\254\346\215\242\346\210\220\345\260\217\345\206\231\345\255\227\346\257\215.md"
@@ -18,14 +18,14 @@
- 示例 1:
-```Python
+```python
输入:s = "Hello"
输出:"hello"
```
- 示例 2:
-```Python
+```python
输入:s = "LOVELY"
输出:"lovely"
```
@@ -47,7 +47,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def toLowerCase(self, s: str) -> str:
ans = ""
@@ -70,7 +70,7 @@ class Solution:
### 思路 2:代码
-```Python
+```python
class Solution:
def toLowerCase(self, s: str) -> str:
return s.lower()
diff --git "a/Solutions/0713. \344\271\230\347\247\257\345\260\217\344\272\216 K \347\232\204\345\255\220\346\225\260\347\273\204.md" "b/Solutions/0713. \344\271\230\347\247\257\345\260\217\344\272\216 K \347\232\204\345\255\220\346\225\260\347\273\204.md"
index d399e3cd..406fadd0 100644
--- "a/Solutions/0713. \344\271\230\347\247\257\345\260\217\344\272\216 K \347\232\204\345\255\220\346\225\260\347\273\204.md"
+++ "b/Solutions/0713. \344\271\230\347\247\257\345\260\217\344\272\216 K \347\232\204\345\255\220\346\225\260\347\273\204.md"
@@ -19,7 +19,7 @@
- 示例 1:
-```Python
+```python
输入:nums = [10,5,2,6], k = 100
输出:8
解释:8 个乘积小于 100 的子数组分别为:[10]、[5]、[2],、[6]、[10,5]、[5,2]、[2,6]、[5,2,6]。需要注意的是 [10,5,2] 并不是乘积小于 100 的子数组。
@@ -27,7 +27,7 @@
- 示例 2:
-```Python
+```python
输入:nums = [1,2,3], k = 0
输出:0
```
@@ -45,7 +45,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def numSubarrayProductLessThanK(self, nums: List[int], k: int) -> int:
if k <= 1:
diff --git "a/Solutions/0714. \344\271\260\345\215\226\350\202\241\347\245\250\347\232\204\346\234\200\344\275\263\346\227\266\346\234\272\345\220\253\346\211\213\347\273\255\350\264\271.md" "b/Solutions/0714. \344\271\260\345\215\226\350\202\241\347\245\250\347\232\204\346\234\200\344\275\263\346\227\266\346\234\272\345\220\253\346\211\213\347\273\255\350\264\271.md"
index a98c9cca..f22375c1 100644
--- "a/Solutions/0714. \344\271\260\345\215\226\350\202\241\347\245\250\347\232\204\346\234\200\344\275\263\346\227\266\346\234\272\345\220\253\346\211\213\347\273\255\350\264\271.md"
+++ "b/Solutions/0714. \344\271\260\345\215\226\350\202\241\347\245\250\347\232\204\346\234\200\344\275\263\346\227\266\346\234\272\345\220\253\346\211\213\347\273\255\350\264\271.md"
@@ -20,7 +20,7 @@
## 代码
-```Python
+```python
class Solution:
def maxProfit(self, prices: List[int], fee: int) -> int:
res = 0
diff --git "a/Solutions/0715. Range \346\250\241\345\235\227.md" "b/Solutions/0715. Range \346\250\241\345\235\227.md"
index 2071c9ff..941a57c0 100644
--- "a/Solutions/0715. Range \346\250\241\345\235\227.md"
+++ "b/Solutions/0715. Range \346\250\241\345\235\227.md"
@@ -47,7 +47,7 @@ rangeModule.queryRange(16, 17) -> True
### 思路 1 代码:
-```Python
+```python
# 线段树的节点类
class TreeNode:
def __init__(self, left, right, val=False, lazy_tag=None, letNode=None, rightNode=None):
diff --git "a/Solutions/0718. \346\234\200\351\225\277\351\207\215\345\244\215\345\255\220\346\225\260\347\273\204.md" "b/Solutions/0718. \346\234\200\351\225\277\351\207\215\345\244\215\345\255\220\346\225\260\347\273\204.md"
index 1cebb0c7..59fe557e 100644
--- "a/Solutions/0718. \346\234\200\351\225\277\351\207\215\345\244\215\345\255\220\346\225\260\347\273\204.md"
+++ "b/Solutions/0718. \346\234\200\351\225\277\351\207\215\345\244\215\345\255\220\346\225\260\347\273\204.md"
@@ -18,7 +18,7 @@
- 示例 1:
-```Python
+```python
输入:nums1 = [1,2,3,2,1], nums2 = [3,2,1,4,7]
输出:3
解释:长度最长的公共子数组是 [3,2,1] 。
@@ -26,7 +26,7 @@
- 示例 2:
-```Python
+```python
输入:nums1 = [0,0,0,0,0], nums2 = [0,0,0,0,0]
输出:5
```
@@ -42,7 +42,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def findLength(self, nums1: List[int], nums2: List[int]) -> int:
size1, size2 = len(nums1), len(nums2)
@@ -69,14 +69,14 @@ class Solution:
我们可以将两个数组分别看做是两把直尺。然后将数组 $nums1$ 固定, 让 $nums2$ 的尾部与 $nums1$ 的头部对齐,如下所示。
-```Python
+```python
nums1 = [1, 2, 3, 2, 1]
nums2 = [3, 2, 1, 4, 7]
```
然后逐渐向右移动直尺 $nums2$,比较 $nums1$ 与 $nums2$ 重叠部分中的公共子数组的长度,直到直尺 $nums2$ 的头部移动到 $nums1$ 的尾部。
-```Python
+```python
nums1 = [1, 2, 3, 2, 1]
nums2 = [3, 2, 1, 4, 7]
@@ -106,7 +106,7 @@ nums2 = [3, 2, 1, 4, 7]
### 思路 2:代码
-```Python
+```python
class Solution:
def findMaxLength(self, nums1, nums2, i, j):
size1, size2 = len(nums1), len(nums2)
@@ -165,7 +165,7 @@ class Solution:
### 思路 3:代码
-```Python
+```python
class Solution:
def findLength(self, nums1: List[int], nums2: List[int]) -> int:
size1 = len(nums1)
diff --git "a/Solutions/0719. \346\211\276\345\207\272\347\254\254 K \345\260\217\347\232\204\346\225\260\345\257\271\350\267\235\347\246\273.md" "b/Solutions/0719. \346\211\276\345\207\272\347\254\254 K \345\260\217\347\232\204\346\225\260\345\257\271\350\267\235\347\246\273.md"
index eb7c7d5e..5a9e7d84 100644
--- "a/Solutions/0719. \346\211\276\345\207\272\347\254\254 K \345\260\217\347\232\204\346\225\260\345\257\271\350\267\235\347\246\273.md"
+++ "b/Solutions/0719. \346\211\276\345\207\272\347\254\254 K \345\260\217\347\232\204\346\225\260\345\257\271\350\267\235\347\246\273.md"
@@ -19,7 +19,7 @@
## 代码
-```Python
+```python
class Solution:
def smallestDistancePair(self, nums: List[int], k: int) -> int:
def get_count(dist):
diff --git "a/Solutions/0720. \350\257\215\345\205\270\344\270\255\346\234\200\351\225\277\347\232\204\345\215\225\350\257\215.md" "b/Solutions/0720. \350\257\215\345\205\270\344\270\255\346\234\200\351\225\277\347\232\204\345\215\225\350\257\215.md"
index f612608b..a27274ac 100644
--- "a/Solutions/0720. \350\257\215\345\205\270\344\270\255\346\234\200\351\225\277\347\232\204\345\215\225\350\257\215.md"
+++ "b/Solutions/0720. \350\257\215\345\205\270\344\270\255\346\234\200\351\225\277\347\232\204\345\215\225\350\257\215.md"
@@ -17,7 +17,7 @@
## 代码
-```Python
+```python
class Trie:
def __init__(self):
diff --git "a/Solutions/0724. \345\257\273\346\211\276\346\225\260\347\273\204\347\232\204\344\270\255\345\277\203\344\270\213\346\240\207.md" "b/Solutions/0724. \345\257\273\346\211\276\346\225\260\347\273\204\347\232\204\344\270\255\345\277\203\344\270\213\346\240\207.md"
index 15039757..92ec60b3 100644
--- "a/Solutions/0724. \345\257\273\346\211\276\346\225\260\347\273\204\347\232\204\344\270\255\345\277\203\344\270\213\346\240\207.md"
+++ "b/Solutions/0724. \345\257\273\346\211\276\346\225\260\347\273\204\347\232\204\344\270\255\345\277\203\344\270\213\346\240\207.md"
@@ -18,7 +18,7 @@
- 示例 1:
-```Python
+```python
输入:nums = [1, 7, 3, 6, 5, 6]
输出:3
解释:
@@ -35,7 +35,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def pivotIndex(self, nums: List[int]) -> int:
sum = 0
diff --git "a/Solutions/0727. \346\234\200\345\260\217\347\252\227\345\217\243\345\255\220\345\272\217\345\210\227.md" "b/Solutions/0727. \346\234\200\345\260\217\347\252\227\345\217\243\345\255\220\345\272\217\345\210\227.md"
index eeccbe40..593093f4 100644
--- "a/Solutions/0727. \346\234\200\345\260\217\347\252\227\345\217\243\345\255\220\345\272\217\345\210\227.md"
+++ "b/Solutions/0727. \346\234\200\345\260\217\347\252\227\345\217\243\345\255\220\345\272\217\345\210\227.md"
@@ -33,7 +33,7 @@
## 代码
-```Python
+```python
class Solution:
def minWindow(self, s1: str, s2: str) -> str:
i, j = 0, 0
diff --git "a/Solutions/0729. \346\210\221\347\232\204\346\227\245\347\250\213\345\256\211\346\216\222\350\241\250 I.md" "b/Solutions/0729. \346\210\221\347\232\204\346\227\245\347\250\213\345\256\211\346\216\222\350\241\250 I.md"
index 89e53808..84b0f164 100644
--- "a/Solutions/0729. \346\210\221\347\232\204\346\227\245\347\250\213\345\256\211\346\216\222\350\241\250 I.md"
+++ "b/Solutions/0729. \346\210\221\347\232\204\346\227\245\347\250\213\345\256\211\346\216\222\350\241\250 I.md"
@@ -24,7 +24,7 @@
- 示例 1:
-```Python
+```python
输入:
["MyCalendar", "book", "book", "book"]
[[], [10, 20], [15, 25], [20, 30]]
@@ -55,7 +55,7 @@ myCalendar.book(20, 30); // return True ,这个日程安排可以添加到日
### 思路 1:线段树代码
-```Python
+```python
# 线段树的节点类
class SegTreeNode:
def __init__(self, left=-1, right=-1, val=0, lazy_tag=None, leftNode=None, rightNode=None):
diff --git "a/Solutions/0731. \346\210\221\347\232\204\346\227\245\347\250\213\345\256\211\346\216\222\350\241\250 II.md" "b/Solutions/0731. \346\210\221\347\232\204\346\227\245\347\250\213\345\256\211\346\216\222\350\241\250 II.md"
index cf1e1be2..b993b11c 100644
--- "a/Solutions/0731. \346\210\221\347\232\204\346\227\245\347\250\213\345\256\211\346\216\222\350\241\250 II.md"
+++ "b/Solutions/0731. \346\210\221\347\232\204\346\227\245\347\250\213\345\256\211\346\216\222\350\241\250 II.md"
@@ -24,7 +24,7 @@
- 示例 1:
-```Python
+```python
输入:
["MyCalendar", "book", "book", "book"]
[[], [10, 20], [15, 25], [20, 30]]
@@ -54,7 +54,7 @@ myCalendar.book(20, 30); // return True ,这个日程安排可以添加到日
### 思路 1:线段树代码
-```Python
+```python
# 线段树的节点类
class SegTreeNode:
def __init__(self, left=-1, right=-1, val=0, lazy_tag=None, leftNode=None, rightNode=None):
diff --git "a/Solutions/0732. \346\210\221\347\232\204\346\227\245\347\250\213\345\256\211\346\216\222\350\241\250 III.md" "b/Solutions/0732. \346\210\221\347\232\204\346\227\245\347\250\213\345\256\211\346\216\222\350\241\250 III.md"
index b6ddf7df..06ee93e3 100644
--- "a/Solutions/0732. \346\210\221\347\232\204\346\227\245\347\250\213\345\256\211\346\216\222\350\241\250 III.md"
+++ "b/Solutions/0732. \346\210\221\347\232\204\346\227\245\347\250\213\345\256\211\346\216\222\350\241\250 III.md"
@@ -24,7 +24,7 @@
- 示例 1:
-```Python
+```python
输入
["MyCalendarThree", "book", "book", "book", "book", "book", "book"]
[[], [10, 20], [50, 60], [10, 40], [5, 15], [5, 10], [25, 55]]
@@ -58,7 +58,7 @@ myCalendarThree.book(25, 55); // 返回 3
### 思路 1:代码
-```Python
+```python
# 线段树的节点类
class SegTreeNode:
def __init__(self, left=-1, right=-1, val=0, lazy_tag=None, leftNode=None, rightNode=None):
diff --git "a/Solutions/0733. \345\233\276\345\203\217\346\270\262\346\237\223.md" "b/Solutions/0733. \345\233\276\345\203\217\346\270\262\346\237\223.md"
index fa569780..4987c96f 100644
--- "a/Solutions/0733. \345\233\276\345\203\217\346\270\262\346\237\223.md"
+++ "b/Solutions/0733. \345\233\276\345\203\217\346\270\262\346\237\223.md"
@@ -17,7 +17,7 @@
## 代码
-```Python
+```python
import collections
class Solution:
diff --git "a/Solutions/0735. \350\241\214\346\230\237\347\242\260\346\222\236.md" "b/Solutions/0735. \350\241\214\346\230\237\347\242\260\346\222\236.md"
index 7d8f6821..ff0314c0 100644
--- "a/Solutions/0735. \350\241\214\346\230\237\347\242\260\346\222\236.md"
+++ "b/Solutions/0735. \350\241\214\346\230\237\347\242\260\346\222\236.md"
@@ -27,7 +27,7 @@
## 代码
-```Python
+```python
class Solution:
def asteroidCollision(self, asteroids: List[int]) -> List[int]:
stack = []
diff --git "a/Solutions/0738. \345\215\225\350\260\203\351\200\222\345\242\236\347\232\204\346\225\260\345\255\227.md" "b/Solutions/0738. \345\215\225\350\260\203\351\200\222\345\242\236\347\232\204\346\225\260\345\255\227.md"
index 0ccf59e3..febff1cc 100644
--- "a/Solutions/0738. \345\215\225\350\260\203\351\200\222\345\242\236\347\232\204\346\225\260\345\255\227.md"
+++ "b/Solutions/0738. \345\215\225\350\260\203\351\200\222\345\242\236\347\232\204\346\225\260\345\255\227.md"
@@ -15,7 +15,7 @@
## 代码
-```Python
+```python
class Solution:
def monotoneIncreasingDigits(self, n: int) -> int:
n_list = list(str(n))
diff --git "a/Solutions/0739. \346\257\217\346\227\245\346\270\251\345\272\246.md" "b/Solutions/0739. \346\257\217\346\227\245\346\270\251\345\272\246.md"
index 2edd8948..702971c3 100644
--- "a/Solutions/0739. \346\257\217\346\227\245\346\270\251\345\272\246.md"
+++ "b/Solutions/0739. \346\257\217\346\227\245\346\270\251\345\272\246.md"
@@ -18,14 +18,14 @@
- 示例 1:
-```Python
+```python
输入: temperatures = [73,74,75,71,69,72,76,73]
输出: [1,1,4,2,1,1,0,0]
```
- 示例 2:
-```Python
+```python
输入: temperatures = [30,40,50,60]
输出: [1,1,1,0]
```
@@ -49,7 +49,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def dailyTemperatures(self, T: List[int]) -> List[int]:
n = len(T)
diff --git "a/Solutions/0744. \345\257\273\346\211\276\346\257\224\347\233\256\346\240\207\345\255\227\346\257\215\345\244\247\347\232\204\346\234\200\345\260\217\345\255\227\346\257\215.md" "b/Solutions/0744. \345\257\273\346\211\276\346\257\224\347\233\256\346\240\207\345\255\227\346\257\215\345\244\247\347\232\204\346\234\200\345\260\217\345\255\227\346\257\215.md"
index 10328d7e..b70c2628 100644
--- "a/Solutions/0744. \345\257\273\346\211\276\346\257\224\347\233\256\346\240\207\345\255\227\346\257\215\345\244\247\347\232\204\346\234\200\345\260\217\345\255\227\346\257\215.md"
+++ "b/Solutions/0744. \345\257\273\346\211\276\346\257\224\347\233\256\346\240\207\345\255\227\346\257\215\345\244\247\347\232\204\346\234\200\345\260\217\345\255\227\346\257\215.md"
@@ -17,7 +17,7 @@
## 代码
-```Python
+```python
class Solution:
def nextGreatestLetter(self, letters: List[str], target: str) -> str:
n = len(letters)
diff --git "a/Solutions/0746. \344\275\277\347\224\250\346\234\200\345\260\217\350\212\261\350\264\271\347\210\254\346\245\274\346\242\257.md" "b/Solutions/0746. \344\275\277\347\224\250\346\234\200\345\260\217\350\212\261\350\264\271\347\210\254\346\245\274\346\242\257.md"
index a59fdde2..199ca660 100644
--- "a/Solutions/0746. \344\275\277\347\224\250\346\234\200\345\260\217\350\212\261\350\264\271\347\210\254\346\245\274\346\242\257.md"
+++ "b/Solutions/0746. \344\275\277\347\224\250\346\234\200\345\260\217\350\212\261\350\264\271\347\210\254\346\245\274\346\242\257.md"
@@ -23,7 +23,7 @@
## 代码
-```Python
+```python
class Solution:
def minCostClimbingStairs(self, cost: List[int]) -> int:
size = len(cost)
diff --git "a/Solutions/0752. \346\211\223\345\274\200\350\275\254\347\233\230\351\224\201.md" "b/Solutions/0752. \346\211\223\345\274\200\350\275\254\347\233\230\351\224\201.md"
index 336a5481..ddd572bb 100644
--- "a/Solutions/0752. \346\211\223\345\274\200\350\275\254\347\233\230\351\224\201.md"
+++ "b/Solutions/0752. \346\211\223\345\274\200\350\275\254\347\233\230\351\224\201.md"
@@ -25,7 +25,7 @@
- 示例 1:
-```Python
+```python
输入:deadends = ["0201","0101","0102","1212","2002"], target = "0202"
输出:6
解释:
@@ -36,7 +36,7 @@
- 示例 2:
-```Python
+```python
输入: deadends = ["8887","8889","8878","8898","8788","8988","7888","9888"], target = "8888"
输出:-1
解释:无法旋转到目标数字且不被锁定。
@@ -59,7 +59,7 @@
### 思路 1:代码
-```Python
+```python
import collections
class Solution:
diff --git "a/Solutions/0758. \345\255\227\347\254\246\344\270\262\344\270\255\347\232\204\345\212\240\347\262\227\345\215\225\350\257\215.md" "b/Solutions/0758. \345\255\227\347\254\246\344\270\262\344\270\255\347\232\204\345\212\240\347\262\227\345\215\225\350\257\215.md"
index 9b465d65..927abaec 100644
--- "a/Solutions/0758. \345\255\227\347\254\246\344\270\262\344\270\255\347\232\204\345\212\240\347\262\227\345\215\225\350\257\215.md"
+++ "b/Solutions/0758. \345\255\227\347\254\246\344\270\262\344\270\255\347\232\204\345\212\240\347\262\227\345\215\225\350\257\215.md"
@@ -19,7 +19,7 @@
## 代码
-```Python
+```python
class Trie:
def __init__(self):
diff --git "a/Solutions/0763. \345\210\222\345\210\206\345\255\227\346\257\215\345\214\272\351\227\264.md" "b/Solutions/0763. \345\210\222\345\210\206\345\255\227\346\257\215\345\214\272\351\227\264.md"
index e05e6d16..864a6762 100644
--- "a/Solutions/0763. \345\210\222\345\210\206\345\255\227\346\257\215\345\214\272\351\227\264.md"
+++ "b/Solutions/0763. \345\210\222\345\210\206\345\255\227\346\257\215\345\214\272\351\227\264.md"
@@ -24,7 +24,7 @@
## 代码
-```Python
+```python
class Solution:
def partitionLabels(self, s: str) -> List[int]:
letter_map = dict()
diff --git "a/Solutions/0765. \346\203\205\344\276\243\347\211\265\346\211\213.md" "b/Solutions/0765. \346\203\205\344\276\243\347\211\265\346\211\213.md"
index 90833691..49149139 100644
--- "a/Solutions/0765. \346\203\205\344\276\243\347\211\265\346\211\213.md"
+++ "b/Solutions/0765. \346\203\205\344\276\243\347\211\265\346\211\213.md"
@@ -23,7 +23,7 @@
- 示例 1:
-```Python
+```python
输入: row = [0,2,1,3]
输出: 1
解释: 只需要交换row[1]和row[2]的位置即可。
@@ -31,7 +31,7 @@
- 示例 2:
-```Python
+```python
输入: row = [3,2,0,1]
输出: 0
解释: 无需交换座位,所有的情侣都已经可以手牵手了。
@@ -56,7 +56,7 @@
### 思路 1:代码
-```Python
+```python
class UnionFind:
def __init__(self, n):
diff --git "a/Solutions/0766. \346\211\230\346\231\256\345\210\251\350\214\250\347\237\251\351\230\265.md" "b/Solutions/0766. \346\211\230\346\231\256\345\210\251\350\214\250\347\237\251\351\230\265.md"
index fb51e7b7..21393b6e 100644
--- "a/Solutions/0766. \346\211\230\346\231\256\345\210\251\350\214\250\347\237\251\351\230\265.md"
+++ "b/Solutions/0766. \346\211\230\346\231\256\345\210\251\350\214\250\347\237\251\351\230\265.md"
@@ -23,7 +23,7 @@

-```Python
+```python
输入:matrix = [[1,2,3,4],[5,1,2,3],[9,5,1,2]]
输出:true
解释:
@@ -36,7 +36,7 @@

-```Python
+```python
输入:matrix = [[1,2],[2,2]]
输出:false
解释:
@@ -53,7 +53,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def isToeplitzMatrix(self, matrix: List[List[int]]) -> bool:
for i in range(1, len(matrix)):
diff --git "a/Solutions/0771. \345\256\235\347\237\263\344\270\216\347\237\263\345\244\264.md" "b/Solutions/0771. \345\256\235\347\237\263\344\270\216\347\237\263\345\244\264.md"
index ab878631..d1695a55 100644
--- "a/Solutions/0771. \345\256\235\347\237\263\344\270\216\347\237\263\345\244\264.md"
+++ "b/Solutions/0771. \345\256\235\347\237\263\344\270\216\347\237\263\345\244\264.md"
@@ -20,14 +20,14 @@
- 示例 1:
-```Python
+```python
输入:jewels = "aA", stones = "aAAbbbb"
输出:3
```
- 示例 2:
-```Python
+```python
输入:jewels = "z", stones = "ZZ"
输出:0
```
@@ -45,7 +45,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def numJewelsInStones(self, jewels: str, stones: str) -> int:
jewel_dict = dict()
diff --git "a/Solutions/0778. \346\260\264\344\275\215\344\270\212\345\215\207\347\232\204\346\263\263\346\261\240\344\270\255\346\270\270\346\263\263.md" "b/Solutions/0778. \346\260\264\344\275\215\344\270\212\345\215\207\347\232\204\346\263\263\346\261\240\344\270\255\346\270\270\346\263\263.md"
index 9e05ad30..49b242d8 100644
--- "a/Solutions/0778. \346\260\264\344\275\215\344\270\212\345\215\207\347\232\204\346\263\263\346\261\240\344\270\255\346\270\270\346\263\263.md"
+++ "b/Solutions/0778. \346\260\264\344\275\215\344\270\212\345\215\207\347\232\204\346\263\263\346\261\240\344\270\255\346\270\270\346\263\263.md"
@@ -27,7 +27,7 @@
## 代码
-```Python
+```python
class UnionFind:
def __init__(self, n):
diff --git "a/Solutions/0779. \347\254\254K\344\270\252\350\257\255\346\263\225\347\254\246\345\217\267.md" "b/Solutions/0779. \347\254\254K\344\270\252\350\257\255\346\263\225\347\254\246\345\217\267.md"
index 9ad0335d..259ebaee 100644
--- "a/Solutions/0779. \347\254\254K\344\270\252\350\257\255\346\263\225\347\254\246\345\217\267.md"
+++ "b/Solutions/0779. \347\254\254K\344\270\252\350\257\255\346\263\225\347\254\246\345\217\267.md"
@@ -21,7 +21,7 @@
- 示例 1:
-```Python
+```python
输入: n = 2, k = 1
输出: 0
解释:
@@ -31,7 +31,7 @@
- 示例 2:
-```Python
+```python
输入: n = 4, k = 4
输出: 0
解释:
@@ -56,7 +56,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def kthGrammar(self, n: int, k: int) -> int:
if n == 0:
diff --git "a/Solutions/0784. \345\255\227\346\257\215\345\244\247\345\260\217\345\206\231\345\205\250\346\216\222\345\210\227.md" "b/Solutions/0784. \345\255\227\346\257\215\345\244\247\345\260\217\345\206\231\345\205\250\346\216\222\345\210\227.md"
index 0b50f45b..89798748 100644
--- "a/Solutions/0784. \345\255\227\346\257\215\345\244\247\345\260\217\345\206\231\345\205\250\346\216\222\345\210\227.md"
+++ "b/Solutions/0784. \345\255\227\346\257\215\345\244\247\345\260\217\345\206\231\345\205\250\346\216\222\345\210\227.md"
@@ -21,7 +21,7 @@
## 代码
-```Python
+```python
class Solution:
def dfs(self, s, path, i, ans):
if i == len(s):
diff --git "a/Solutions/0785. \345\210\244\346\226\255\344\272\214\345\210\206\345\233\276.md" "b/Solutions/0785. \345\210\244\346\226\255\344\272\214\345\210\206\345\233\276.md"
index acea48b6..6da4c9b5 100644
--- "a/Solutions/0785. \345\210\244\346\226\255\344\272\214\345\210\206\345\233\276.md"
+++ "b/Solutions/0785. \345\210\244\346\226\255\344\272\214\345\210\206\345\233\276.md"
@@ -31,7 +31,7 @@
## 代码
-```Python
+```python
class Solution:
def dfs(self, graph, colors, i, color):
colors[i] = color
diff --git "a/Solutions/0788. \346\227\213\350\275\254\346\225\260\345\255\227.md" "b/Solutions/0788. \346\227\213\350\275\254\346\225\260\345\255\227.md"
index f3f6d705..5ef0e5b1 100644
--- "a/Solutions/0788. \346\227\213\350\275\254\346\225\260\345\255\227.md"
+++ "b/Solutions/0788. \346\227\213\350\275\254\346\225\260\345\255\227.md"
@@ -19,7 +19,7 @@
- 示例 1:
-```Python
+```python
输入: 10
输出: 4
解释:
@@ -39,7 +39,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def rotatedDigits(self, n: int) -> int:
check = [0, 0, 1, -1, -1, 1, 1, -1, 0, 1]
@@ -94,7 +94,7 @@ class Solution:
### 思路 2:代码
-```Python
+```python
class Solution:
def rotatedDigits(self, n: int) -> int:
check = [0, 0, 1, -1, -1, 1, 1, -1, 0, 1]
diff --git "a/Solutions/0795. \345\214\272\351\227\264\345\255\220\346\225\260\347\273\204\344\270\252\346\225\260.md" "b/Solutions/0795. \345\214\272\351\227\264\345\255\220\346\225\260\347\273\204\344\270\252\346\225\260.md"
index 60828efa..5f373daa 100644
--- "a/Solutions/0795. \345\214\272\351\227\264\345\255\220\346\225\260\347\273\204\344\270\252\346\225\260.md"
+++ "b/Solutions/0795. \345\214\272\351\227\264\345\255\220\346\225\260\347\273\204\344\270\252\346\225\260.md"
@@ -19,7 +19,7 @@
## 代码
-```Python
+```python
class Solution:
def numSubarrayMaxK(self, nums, k):
ans = 0
diff --git "a/Solutions/0796. \346\227\213\350\275\254\345\255\227\347\254\246\344\270\262.md" "b/Solutions/0796. \346\227\213\350\275\254\345\255\227\347\254\246\344\270\262.md"
index 179ab166..e7213c4b 100644
--- "a/Solutions/0796. \346\227\213\350\275\254\345\255\227\347\254\246\344\270\262.md"
+++ "b/Solutions/0796. \346\227\213\350\275\254\345\255\227\347\254\246\344\270\262.md"
@@ -20,14 +20,14 @@
- 示例 1:
-```Python
+```python
输入: s = "abcde", goal = "cdeab"
输出: true
```
- 示例 2:
-```Python
+```python
输入: s = "abcde", goal = "abced"
输出: false
```
@@ -45,7 +45,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def kmp(self, T: str, p: str) -> int:
n, m = len(T), len(p)
diff --git "a/Solutions/0797. \346\211\200\346\234\211\345\217\257\350\203\275\347\232\204\350\267\257\345\276\204.md" "b/Solutions/0797. \346\211\200\346\234\211\345\217\257\350\203\275\347\232\204\350\267\257\345\276\204.md"
index 362e2f2c..295cc188 100644
--- "a/Solutions/0797. \346\211\200\346\234\211\345\217\257\350\203\275\347\232\204\350\267\257\345\276\204.md"
+++ "b/Solutions/0797. \346\211\200\346\234\211\345\217\257\350\203\275\347\232\204\350\267\257\345\276\204.md"
@@ -26,7 +26,7 @@
## 代码
-```Python
+```python
class Solution:
def dfs(self, graph, start, target, path, ans):
if start == target:
diff --git "a/Solutions/0800. \347\233\270\344\274\274 RGB \351\242\234\350\211\262.md" "b/Solutions/0800. \347\233\270\344\274\274 RGB \351\242\234\350\211\262.md"
index 43a1831b..a636822a 100644
--- "a/Solutions/0800. \347\233\270\344\274\274 RGB \351\242\234\350\211\262.md"
+++ "b/Solutions/0800. \347\233\270\344\274\274 RGB \351\242\234\350\211\262.md"
@@ -17,7 +17,7 @@
- 示例 1:
-```Python
+```python
输入 color = "#09f166"
输出 "#11ee66"
解释: 因为相似度计算得出 -(0x09 - 0x11)^2 -(0xf1 - 0xee)^2 - (0x66 - 0x66)^2 = -64 -9 -0 = -73,这是所有可以简写的颜色中与 color 最相似的颜色
@@ -36,7 +36,7 @@
### 思路 1:枚举算法代码
-```Python
+```python
class Solution:
def similar(self, hex1, hex2):
r1, g1, b1 = hex1 >> 16, (hex1 >> 8) % 256, hex1 % 256
diff --git "a/Solutions/0801. \344\275\277\345\272\217\345\210\227\351\200\222\345\242\236\347\232\204\346\234\200\345\260\217\344\272\244\346\215\242\346\254\241\346\225\260.md" "b/Solutions/0801. \344\275\277\345\272\217\345\210\227\351\200\222\345\242\236\347\232\204\346\234\200\345\260\217\344\272\244\346\215\242\346\254\241\346\225\260.md"
index 26d3a43b..edb756bb 100644
--- "a/Solutions/0801. \344\275\277\345\272\217\345\210\227\351\200\222\345\242\236\347\232\204\346\234\200\345\260\217\344\272\244\346\215\242\346\254\241\346\225\260.md"
+++ "b/Solutions/0801. \344\275\277\345\272\217\345\210\227\351\200\222\345\242\236\347\232\204\346\234\200\345\260\217\344\272\244\346\215\242\346\254\241\346\225\260.md"
@@ -53,7 +53,7 @@
## 代码
-```Python
+```python
class Solution:
def minSwap(self, nums1: List[int], nums2: List[int]) -> int:
size = len(nums1)
diff --git "a/Solutions/0802. \346\211\276\345\210\260\346\234\200\347\273\210\347\232\204\345\256\211\345\205\250\347\212\266\346\200\201.md" "b/Solutions/0802. \346\211\276\345\210\260\346\234\200\347\273\210\347\232\204\345\256\211\345\205\250\347\212\266\346\200\201.md"
index da8c2314..9d27f751 100644
--- "a/Solutions/0802. \346\211\276\345\210\260\346\234\200\347\273\210\347\232\204\345\256\211\345\205\250\347\212\266\346\200\201.md"
+++ "b/Solutions/0802. \346\211\276\345\210\260\346\234\200\347\273\210\347\232\204\345\256\211\345\205\250\347\212\266\346\200\201.md"
@@ -27,7 +27,7 @@

-```Python
+```python
输入:graph = [[1,2],[2,3],[5],[0],[5],[],[]]
输出:[2,4,5,6]
解释:示意图如上。
@@ -37,7 +37,7 @@
- 示例 2:
-```Python
+```python
输入:graph = [[1,2,3,4],[1,2],[3,4],[0,4],[]]
输出:[4]
解释:
@@ -56,7 +56,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
# 拓扑排序,graph 中包含所有顶点的有向边关系(包括无边顶点)
def topologicalSortingKahn(self, graph: dict):
diff --git "a/Solutions/0803. \346\211\223\347\240\226\345\235\227.md" "b/Solutions/0803. \346\211\223\347\240\226\345\235\227.md"
index ff40e593..7435ac99 100644
--- "a/Solutions/0803. \346\211\223\347\240\226\345\235\227.md"
+++ "b/Solutions/0803. \346\211\223\347\240\226\345\235\227.md"
@@ -41,7 +41,7 @@
## 代码
-```Python
+```python
class UnionFind:
def __init__(self, n):
self.parent = [i for i in range(n)]
diff --git "a/Solutions/0806. \345\206\231\345\255\227\347\254\246\344\270\262\351\234\200\350\246\201\347\232\204\350\241\214\346\225\260.md" "b/Solutions/0806. \345\206\231\345\255\227\347\254\246\344\270\262\351\234\200\350\246\201\347\232\204\350\241\214\346\225\260.md"
index 259ebc96..f7cd6248 100644
--- "a/Solutions/0806. \345\206\231\345\255\227\347\254\246\344\270\262\351\234\200\350\246\201\347\232\204\350\241\214\346\225\260.md"
+++ "b/Solutions/0806. \345\206\231\345\255\227\347\254\246\344\270\262\351\234\200\350\246\201\347\232\204\350\241\214\346\225\260.md"
@@ -20,7 +20,7 @@
- 示例 1:
-```Python
+```python
输入:
widths = [10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10]
S = "abcdefghijklmnopqrstuvwxyz"
@@ -32,7 +32,7 @@ S = "abcdefghijklmnopqrstuvwxyz"
- 示例 2:
-```Python
+```python
输入:
widths = [4,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10]
S = "bbbcccdddaaa"
@@ -55,7 +55,7 @@ S = "bbbcccdddaaa"
### 思路 1:代码
-```Python
+```python
class Solution:
def numberOfLines(self, widths: List[int], s: str) -> List[int]:
line_cnt, last_cnt = 1, 0
diff --git "a/Solutions/0811. \345\255\220\345\237\237\345\220\215\350\256\277\351\227\256\350\256\241\346\225\260.md" "b/Solutions/0811. \345\255\220\345\237\237\345\220\215\350\256\277\351\227\256\350\256\241\346\225\260.md"
index dbaf71b2..4b1f8a85 100644
--- "a/Solutions/0811. \345\255\220\345\237\237\345\220\215\350\256\277\351\227\256\350\256\241\346\225\260.md"
+++ "b/Solutions/0811. \345\255\220\345\237\237\345\220\215\350\256\277\351\227\256\350\256\241\346\225\260.md"
@@ -35,7 +35,7 @@
## 代码
-```Python
+```python
class Solution:
def subdomainVisits(self, cpdomains: List[str]) -> List[str]:
if not cpdomains:
diff --git "a/Solutions/0814. \344\272\214\345\217\211\346\240\221\345\211\252\346\236\235.md" "b/Solutions/0814. \344\272\214\345\217\211\346\240\221\345\211\252\346\236\235.md"
index a0488f16..a3bb1db0 100644
--- "a/Solutions/0814. \344\272\214\345\217\211\346\240\221\345\211\252\346\236\235.md"
+++ "b/Solutions/0814. \344\272\214\345\217\211\346\240\221\345\211\252\346\236\235.md"
@@ -21,7 +21,7 @@
## 代码
-```Python
+```python
class Solution:
def containsOnlyZero(self, root: TreeNode):
if not root:
diff --git "a/Solutions/0819. \346\234\200\345\270\270\350\247\201\347\232\204\345\215\225\350\257\215.md" "b/Solutions/0819. \346\234\200\345\270\270\350\247\201\347\232\204\345\215\225\350\257\215.md"
index bcadabf1..95392daa 100644
--- "a/Solutions/0819. \346\234\200\345\270\270\350\247\201\347\232\204\345\215\225\350\257\215.md"
+++ "b/Solutions/0819. \346\234\200\345\270\270\350\247\201\347\232\204\345\215\225\350\257\215.md"
@@ -26,7 +26,7 @@
- 示例 1:
-```Python
+```python
输入:
paragraph = "Bob hit a ball, the hit BALL flew far after it was hit."
banned = ["hit"]
@@ -40,7 +40,7 @@ banned = ["hit"]
- 示例 2:
-```Python
+```python
输入:
paragraph = "a."
banned = []
@@ -58,7 +58,7 @@ banned = []
### 思路 1:代码
-```Python
+```python
class Solution:
def mostCommonWord(self, paragraph: str, banned: List[str]) -> str:
banned_set = set(banned)
diff --git "a/Solutions/0820. \345\215\225\350\257\215\347\232\204\345\216\213\347\274\251\347\274\226\347\240\201.md" "b/Solutions/0820. \345\215\225\350\257\215\347\232\204\345\216\213\347\274\251\347\274\226\347\240\201.md"
index ea3a7624..56e8ea1e 100644
--- "a/Solutions/0820. \345\215\225\350\257\215\347\232\204\345\216\213\347\274\251\347\274\226\347\240\201.md"
+++ "b/Solutions/0820. \345\215\225\350\257\215\347\232\204\345\216\213\347\274\251\347\274\226\347\240\201.md"
@@ -19,7 +19,7 @@
## 代码
-```Python
+```python
class Trie:
def __init__(self):
diff --git "a/Solutions/0821. \345\255\227\347\254\246\347\232\204\346\234\200\347\237\255\350\267\235\347\246\273.md" "b/Solutions/0821. \345\255\227\347\254\246\347\232\204\346\234\200\347\237\255\350\267\235\347\246\273.md"
index c263f1d2..d4932c85 100644
--- "a/Solutions/0821. \345\255\227\347\254\246\347\232\204\346\234\200\347\237\255\350\267\235\347\246\273.md"
+++ "b/Solutions/0821. \345\255\227\347\254\246\347\232\204\346\234\200\347\237\255\350\267\235\347\246\273.md"
@@ -20,7 +20,7 @@
- 示例 1:
-```Python
+```python
输入:s = "loveleetcode", c = "e"
输出:[3,2,1,0,1,0,0,1,2,2,1,0]
解释:字符 'e' 出现在下标 3、5、6 和 11 处(下标从 0 开始计数)。
@@ -32,7 +32,7 @@
- 示例 2:
-```Python
+```python
输入:s = "aaab", c = "b"
输出:[3,2,1,0]
```
@@ -47,7 +47,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def shortestToChar(self, s: str, c: str) -> List[int]:
size = len(s)
diff --git "a/Solutions/0824. \345\261\261\347\276\212\346\213\211\344\270\201\346\226\207.md" "b/Solutions/0824. \345\261\261\347\276\212\346\213\211\344\270\201\346\226\207.md"
index 9ce13aac..5f9d43ad 100644
--- "a/Solutions/0824. \345\261\261\347\276\212\346\213\211\344\270\201\346\226\207.md"
+++ "b/Solutions/0824. \345\261\261\347\276\212\346\213\211\344\270\201\346\226\207.md"
@@ -30,14 +30,14 @@
- 示例 1:
-```Python
+```python
输入:sentence = "I speak Goat Latin"
输出:"Imaa peaksmaaa oatGmaaaa atinLmaaaaa"
```
- 示例 2:
-```Python
+```python
输入:sentence = "The quick brown fox jumped over the lazy dog"
输出:"heTmaa uickqmaaa rownbmaaaa oxfmaaaaa umpedjmaaaaaa overmaaaaaaa hetmaaaaaaaa azylmaaaaaaaaa ogdmaaaaaaaaaa"
```
@@ -52,7 +52,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def toGoatLatin(self, sentence: str) -> str:
vowels = set(['a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U'])
diff --git "a/Solutions/0830. \350\276\203\345\244\247\345\210\206\347\273\204\347\232\204\344\275\215\347\275\256.md" "b/Solutions/0830. \350\276\203\345\244\247\345\210\206\347\273\204\347\232\204\344\275\215\347\275\256.md"
index d7ce496b..119e9ea5 100644
--- "a/Solutions/0830. \350\276\203\345\244\247\345\210\206\347\273\204\347\232\204\344\275\215\347\275\256.md"
+++ "b/Solutions/0830. \350\276\203\345\244\247\345\210\206\347\273\204\347\232\204\344\275\215\347\275\256.md"
@@ -17,7 +17,7 @@
- 示例 1:
-```Python
+```python
输入:s = "abbxxxxzzy"
输出:[[3,6]]
解释:"xxxx" 是一个起始于 3 且终止于 6 的较大分组。
@@ -25,7 +25,7 @@
- 示例 2:
-```Python
+```python
输入:s = "abc"
输出:[]
解释:"a","b" 和 "c" 均不是符合要求的较大分组。
@@ -46,7 +46,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def largeGroupPositions(self, s: str) -> List[List[int]]:
res = []
diff --git "a/Solutions/0832. \347\277\273\350\275\254\345\233\276\345\203\217.md" "b/Solutions/0832. \347\277\273\350\275\254\345\233\276\345\203\217.md"
index 6c98f030..378fd3e2 100644
--- "a/Solutions/0832. \347\277\273\350\275\254\345\233\276\345\203\217.md"
+++ "b/Solutions/0832. \347\277\273\350\275\254\345\233\276\345\203\217.md"
@@ -13,7 +13,7 @@
## 代码
-```Python
+```python
class Solution:
def flipAndInvertImage(self, image: List[List[int]]) -> List[List[int]]:
n = len(image)
diff --git "a/Solutions/0834. \346\240\221\344\270\255\350\267\235\347\246\273\344\271\213\345\222\214.md" "b/Solutions/0834. \346\240\221\344\270\255\350\267\235\347\246\273\344\271\213\345\222\214.md"
index ecc3ac85..4876ebe4 100644
--- "a/Solutions/0834. \346\240\221\344\270\255\350\267\235\347\246\273\344\271\213\345\222\214.md"
+++ "b/Solutions/0834. \346\240\221\344\270\255\350\267\235\347\246\273\344\271\213\345\222\214.md"
@@ -26,7 +26,7 @@

-```Python
+```python
输入: n = 6, edges = [[0,1],[0,2],[2,3],[2,4],[2,5]]
输出: [8,12,6,10,10,10]
解释: 树如图所示。
@@ -38,7 +38,7 @@

-```Python
+```python
输入: n = 2, edges = [[1,0]]
输出: [1,1]
```
@@ -68,7 +68,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def sumOfDistancesInTree(self, n: int, edges: List[List[int]]) -> List[int]:
graph = [[] for _ in range(n)]
diff --git "a/Solutions/0836. \347\237\251\345\275\242\351\207\215\345\217\240.md" "b/Solutions/0836. \347\237\251\345\275\242\351\207\215\345\217\240.md"
index 99e352f5..d0e10522 100644
--- "a/Solutions/0836. \347\237\251\345\275\242\351\207\215\345\217\240.md"
+++ "b/Solutions/0836. \347\237\251\345\275\242\351\207\215\345\217\240.md"
@@ -21,7 +21,7 @@
## 代码
-```Python
+```python
class Solution:
def isRectangleOverlap(self, rec1: List[int], rec2: List[int]) -> bool:
return min(rec1[2], rec2[2]) > max(rec1[0], rec2[0]) and min(rec1[3], rec2[3]) > max(rec1[1], rec2[1])
diff --git "a/Solutions/0841. \351\222\245\345\214\231\345\222\214\346\210\277\351\227\264.md" "b/Solutions/0841. \351\222\245\345\214\231\345\222\214\346\210\277\351\227\264.md"
index c2090d02..278b7ffc 100644
--- "a/Solutions/0841. \351\222\245\345\214\231\345\222\214\346\210\277\351\227\264.md"
+++ "b/Solutions/0841. \351\222\245\345\214\231\345\222\214\346\210\277\351\227\264.md"
@@ -24,7 +24,7 @@
- 示例 1:
-```Python
+```python
输入:rooms = [[1],[2],[3],[]]
输出:True
解释:
@@ -37,7 +37,7 @@
- 示例 2:
-```Python
+```python
输入:rooms = [[1,3],[3,0,1],[2],[0]]
输出:False
解释:我们不能进入 2 号房间。
@@ -63,7 +63,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def canVisitAllRooms(self, rooms: List[List[int]]) -> bool:
def dfs(x):
diff --git "a/Solutions/0844. \346\257\224\350\276\203\345\220\253\351\200\200\346\240\274\347\232\204\345\255\227\347\254\246\344\270\262.md" "b/Solutions/0844. \346\257\224\350\276\203\345\220\253\351\200\200\346\240\274\347\232\204\345\255\227\347\254\246\344\270\262.md"
index 31f1e22d..e1c38a2f 100644
--- "a/Solutions/0844. \346\257\224\350\276\203\345\220\253\351\200\200\346\240\274\347\232\204\345\255\227\347\254\246\344\270\262.md"
+++ "b/Solutions/0844. \346\257\224\350\276\203\345\220\253\351\200\200\346\240\274\347\232\204\345\255\227\347\254\246\344\270\262.md"
@@ -46,7 +46,7 @@
- 思路一:
-```Python
+```python
class Solution:
def build(self, s: str):
stack = []
@@ -63,7 +63,7 @@ class Solution:
- 思路二:
-```Python
+```python
class Solution:
def backspaceCompare(self, s: str, t: str) -> bool:
left_1, left_2 = len(s) - 1, len(t) - 1
diff --git "a/Solutions/0845. \346\225\260\347\273\204\344\270\255\347\232\204\346\234\200\351\225\277\345\261\261\350\204\211.md" "b/Solutions/0845. \346\225\260\347\273\204\344\270\255\347\232\204\346\234\200\351\225\277\345\261\261\350\204\211.md"
index c2308ebf..4212a8fd 100644
--- "a/Solutions/0845. \346\225\260\347\273\204\344\270\255\347\232\204\346\234\200\351\225\277\345\261\261\350\204\211.md"
+++ "b/Solutions/0845. \346\225\260\347\273\204\344\270\255\347\232\204\346\234\200\351\225\277\345\261\261\350\204\211.md"
@@ -21,7 +21,7 @@
## 代码
-```Python
+```python
class Solution:
def longestMountain(self, arr: List[int]) -> int:
size = len(arr)
diff --git "a/Solutions/0846. \344\270\200\346\211\213\351\241\272\345\255\220.md" "b/Solutions/0846. \344\270\200\346\211\213\351\241\272\345\255\220.md"
index e4f7abc7..e4d38fd1 100644
--- "a/Solutions/0846. \344\270\200\346\211\213\351\241\272\345\255\220.md"
+++ "b/Solutions/0846. \344\270\200\346\211\213\351\241\272\345\255\220.md"
@@ -19,7 +19,7 @@
- 示例 1:
-```Python
+```python
输入:hand = [1,2,3,6,2,3,4,7,8], groupSize = 3
输出:True
解释:Alice 手中的牌可以被重新排列为 [1,2,3],[2,3,4],[6,7,8]。
@@ -36,7 +36,7 @@
### 思路 1:哈希表 + 排序代码
-```Python
+```python
class Solution:
def isPossibleDivide(self, nums: List[int], k: int) -> bool:
hand_map = collections.defaultdict(int)
diff --git "a/Solutions/0847. \350\256\277\351\227\256\346\211\200\346\234\211\350\212\202\347\202\271\347\232\204\346\234\200\347\237\255\350\267\257\345\276\204.md" "b/Solutions/0847. \350\256\277\351\227\256\346\211\200\346\234\211\350\212\202\347\202\271\347\232\204\346\234\200\347\237\255\350\267\257\345\276\204.md"
index 82ead3e4..1fb4d173 100644
--- "a/Solutions/0847. \350\256\277\351\227\256\346\211\200\346\234\211\350\212\202\347\202\271\347\232\204\346\234\200\347\237\255\350\267\257\345\276\204.md"
+++ "b/Solutions/0847. \350\256\277\351\227\256\346\211\200\346\234\211\350\212\202\347\202\271\347\232\204\346\234\200\347\237\255\350\267\257\345\276\204.md"
@@ -24,7 +24,7 @@

-```Python
+```python
输入:graph = [[1,2,3],[0],[0],[0]]
输出:4
解释:一种可能的路径为 [1,0,2,0,3]
@@ -34,7 +34,7 @@

-```Python
+```python
输入:graph = [[1],[0,2,4],[1,3,4],[2],[1,2]]
输出:4
解释:一种可能的路径为 [0,1,4,2,3]
@@ -73,7 +73,7 @@
### 思路 1:代码
-```Python
+```python
import collections
diff --git "a/Solutions/0850. \347\237\251\345\275\242\351\235\242\347\247\257 II.md" "b/Solutions/0850. \347\237\251\345\275\242\351\235\242\347\247\257 II.md"
index efe879f6..fc881a04 100644
--- "a/Solutions/0850. \347\237\251\345\275\242\351\235\242\347\247\257 II.md"
+++ "b/Solutions/0850. \347\237\251\345\275\242\351\235\242\347\247\257 II.md"
@@ -24,7 +24,7 @@

-```Python
+```python
输入:rectangles = [[0,0,2,2],[1,0,2,3],[1,0,3,1]]
输出:6
解释:如图所示,三个矩形覆盖了总面积为6的区域。
@@ -40,7 +40,7 @@
### 思路 1:扫描线 + 动态开点线段树代码
-```Python
+```python
# 线段树的节点类
class SegTreeNode:
def __init__(self, left=-1, right=-1, cnt=0, height=0, leftNode=None, rightNode=None):
diff --git "a/Solutions/0851. \345\226\247\351\227\271\345\222\214\345\257\214\346\234\211.md" "b/Solutions/0851. \345\226\247\351\227\271\345\222\214\345\257\214\346\234\211.md"
index 4c2ad692..45ee7ba8 100644
--- "a/Solutions/0851. \345\226\247\351\227\271\345\222\214\345\257\214\346\234\211.md"
+++ "b/Solutions/0851. \345\226\247\351\227\271\345\222\214\345\257\214\346\234\211.md"
@@ -27,7 +27,7 @@
- 示例 1:
-```Python
+```python
输入:richer = [[1,0],[2,1],[3,1],[3,7],[4,3],[5,3],[6,3]], quiet = [3,2,5,4,6,1,7,0]
输出:[5,5,2,5,4,5,6,7]
@@ -54,7 +54,7 @@ answer[7] = 7,
### 思路 1:拓扑排序代码
-```Python
+```python
import collections
class Solution:
diff --git "a/Solutions/0852. \345\261\261\350\204\211\346\225\260\347\273\204\347\232\204\345\263\260\351\241\266\347\264\242\345\274\225.md" "b/Solutions/0852. \345\261\261\350\204\211\346\225\260\347\273\204\347\232\204\345\263\260\351\241\266\347\264\242\345\274\225.md"
index 45faa853..da853ee1 100644
--- "a/Solutions/0852. \345\261\261\350\204\211\346\225\260\347\273\204\347\232\204\345\263\260\351\241\266\347\264\242\345\274\225.md"
+++ "b/Solutions/0852. \345\261\261\350\204\211\346\225\260\347\273\204\347\232\204\345\263\260\351\241\266\347\264\242\345\274\225.md"
@@ -28,7 +28,7 @@
## 代码
-```Python
+```python
class Solution:
def peakIndexInMountainArray(self, arr: List[int]) -> int:
left = 0
diff --git "a/Solutions/0860. \346\237\240\346\252\254\346\260\264\346\211\276\351\233\266.md" "b/Solutions/0860. \346\237\240\346\252\254\346\260\264\346\211\276\351\233\266.md"
index b67e9338..1d2ae6fd 100644
--- "a/Solutions/0860. \346\237\240\346\252\254\346\260\264\346\211\276\351\233\266.md"
+++ "b/Solutions/0860. \346\237\240\346\252\254\346\260\264\346\211\276\351\233\266.md"
@@ -21,7 +21,7 @@
- 示例 1:
-```Python
+```python
输入:bills = [5,5,5,10,20]
输出:True
解释:
@@ -33,7 +33,7 @@
- 示例 2:
-```Python
+```python
输入:bills = [5,5,10,10,20]
输出:False
解释:
@@ -57,7 +57,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def lemonadeChange(self, bills: List[int]) -> bool:
five, ten, twenty = 0, 0, 0
diff --git "a/Solutions/0861. \347\277\273\350\275\254\347\237\251\351\230\265\345\220\216\347\232\204\345\276\227\345\210\206.md" "b/Solutions/0861. \347\277\273\350\275\254\347\237\251\351\230\265\345\220\216\347\232\204\345\276\227\345\210\206.md"
index 474bdbcf..29a38e5f 100644
--- "a/Solutions/0861. \347\277\273\350\275\254\347\237\251\351\230\265\345\220\216\347\232\204\345\276\227\345\210\206.md"
+++ "b/Solutions/0861. \347\277\273\350\275\254\347\237\251\351\230\265\345\220\216\347\232\204\345\276\227\345\210\206.md"
@@ -23,7 +23,7 @@
- 示例 1:
-```Python
+```python
输入:[[0,0,1,1],[1,0,1,0],[1,1,0,0]]
输出:39
解释:
@@ -44,7 +44,7 @@
### 思路 1:贪心算法代码
-```Python
+```python
class Solution:
def matrixScore(self, grid: List[List[int]]) -> int:
zero_cnt, one_cnt = 0, 0
diff --git "a/Solutions/0867. \350\275\254\347\275\256\347\237\251\351\230\265.md" "b/Solutions/0867. \350\275\254\347\275\256\347\237\251\351\230\265.md"
index 8b2453f4..c5135c6a 100644
--- "a/Solutions/0867. \350\275\254\347\275\256\347\237\251\351\230\265.md"
+++ "b/Solutions/0867. \350\275\254\347\275\256\347\237\251\351\230\265.md"
@@ -13,7 +13,7 @@
## 代码
-```Python
+```python
class Solution:
def transpose(self, matrix: List[List[int]]) -> List[List[int]]:
m = len(matrix)
diff --git "a/Solutions/0872. \345\217\266\345\255\220\347\233\270\344\274\274\347\232\204\346\240\221.md" "b/Solutions/0872. \345\217\266\345\255\220\347\233\270\344\274\274\347\232\204\346\240\221.md"
index 2e4ab2d1..b55a3318 100644
--- "a/Solutions/0872. \345\217\266\345\255\220\347\233\270\344\274\274\347\232\204\346\240\221.md"
+++ "b/Solutions/0872. \345\217\266\345\255\220\347\233\270\344\274\274\347\232\204\346\240\221.md"
@@ -15,7 +15,7 @@
## 代码
-```Python
+```python
class Solution:
def leafSimilar(self, root1: TreeNode, root2: TreeNode) -> bool:
def dfs(node: TreeNode, res: List[int]):
diff --git "a/Solutions/0873. \346\234\200\351\225\277\347\232\204\346\226\220\346\263\242\351\202\243\345\245\221\345\255\220\345\272\217\345\210\227\347\232\204\351\225\277\345\272\246.md" "b/Solutions/0873. \346\234\200\351\225\277\347\232\204\346\226\220\346\263\242\351\202\243\345\245\221\345\255\220\345\272\217\345\210\227\347\232\204\351\225\277\345\272\246.md"
index dffe66ff..7a150131 100644
--- "a/Solutions/0873. \346\234\200\351\225\277\347\232\204\346\226\220\346\263\242\351\202\243\345\245\221\345\255\220\345\272\217\345\210\227\347\232\204\351\225\277\345\272\246.md"
+++ "b/Solutions/0873. \346\234\200\351\225\277\347\232\204\346\226\220\346\263\242\351\202\243\345\245\221\345\255\220\345\272\217\345\210\227\347\232\204\351\225\277\345\272\246.md"
@@ -28,7 +28,7 @@
- 示例 1:
-```Python
+```python
输入: arr = [1,2,3,4,5,6,7,8]
输出: 5
解释: 最长的斐波那契式子序列为 [1,2,3,5,8]。
@@ -36,7 +36,7 @@
- 示例 2:
-```Python
+```python
输入: arr = [1,3,7,11,12,14,18]
输出: 3
解释: 最长的斐波那契式子序列有 [1,11,12]、[3,11,14] 以及 [7,11,18]。
@@ -58,7 +58,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def lenLongestFibSubseq(self, arr: List[int]) -> int:
size = len(arr)
@@ -95,7 +95,7 @@ class Solution:
### 思路 2:代码
-```Python
+```python
class Solution:
def lenLongestFibSubseq(self, arr: List[int]) -> int:
size = len(arr)
@@ -157,7 +157,7 @@ class Solution:
### 思路 3:代码
-```Python
+```python
class Solution:
def lenLongestFibSubseq(self, arr: List[int]) -> int:
size = len(arr)
diff --git "a/Solutions/0875. \347\210\261\345\220\203\351\246\231\350\225\211\347\232\204\347\217\202\347\217\202.md" "b/Solutions/0875. \347\210\261\345\220\203\351\246\231\350\225\211\347\232\204\347\217\202\347\217\202.md"
index 9175b98c..f942c661 100644
--- "a/Solutions/0875. \347\210\261\345\220\203\351\246\231\350\225\211\347\232\204\347\217\202\347\217\202.md"
+++ "b/Solutions/0875. \347\210\261\345\220\203\351\246\231\350\225\211\347\232\204\347\217\202\347\217\202.md"
@@ -24,7 +24,7 @@
## 代码
-```Python
+```python
class Solution:
def canEat(self, piles, hour, speed):
time = 0
diff --git "a/Solutions/0876. \351\223\276\350\241\250\347\232\204\344\270\255\351\227\264\347\273\223\347\202\271.md" "b/Solutions/0876. \351\223\276\350\241\250\347\232\204\344\270\255\351\227\264\347\273\223\347\202\271.md"
index 194dc6c1..7effbd71 100644
--- "a/Solutions/0876. \351\223\276\350\241\250\347\232\204\344\270\255\351\227\264\347\273\223\347\202\271.md"
+++ "b/Solutions/0876. \351\223\276\350\241\250\347\232\204\344\270\255\351\227\264\347\273\223\347\202\271.md"
@@ -17,7 +17,7 @@
- 示例 1:
-```Python
+```python
输入:[1,2,3,4,5]
输出:此列表中的结点 3 (序列化形式:[3,4,5])
解释:返回的结点值为 3 。
@@ -27,7 +27,7 @@ ans.val = 3, ans.next.val = 4, ans.next.next.val = 5, 以及 ans.next.next.next
- 示例 2:
-```Python
+```python
输入:[1,2,3,4,5,6]
输出:此列表中的结点 4 (序列化形式:[4,5,6])
解释:由于该列表有两个中间结点,值分别为 3 和 4,我们返回第二个结点。
@@ -41,7 +41,7 @@ ans.val = 3, ans.next.val = 4, ans.next.next.val = 5, 以及 ans.next.next.next
### 思路 1:代码
-```Python
+```python
class Solution:
def middleNode(self, head: ListNode) -> ListNode:
n = 0
@@ -73,7 +73,7 @@ class Solution:
### 思路 2:代码
-```Python
+```python
class Solution:
def middleNode(self, head: ListNode) -> ListNode:
fast = head
diff --git "a/Solutions/0877. \347\237\263\345\255\220\346\270\270\346\210\217.md" "b/Solutions/0877. \347\237\263\345\255\220\346\270\270\346\210\217.md"
index 7701d3a4..9feacac2 100644
--- "a/Solutions/0877. \347\237\263\345\255\220\346\270\270\346\210\217.md"
+++ "b/Solutions/0877. \347\237\263\345\255\220\346\270\270\346\210\217.md"
@@ -22,7 +22,7 @@
## 代码
-```Python
+```python
class Solution:
def stoneGame(self, piles: List[int]) -> bool:
return True
diff --git "a/Solutions/0881. \346\225\221\347\224\237\350\211\207.md" "b/Solutions/0881. \346\225\221\347\224\237\350\211\207.md"
index f6420feb..37000d17 100644
--- "a/Solutions/0881. \346\225\221\347\224\237\350\211\207.md"
+++ "b/Solutions/0881. \346\225\221\347\224\237\350\211\207.md"
@@ -18,7 +18,7 @@
- 示例 1:
-```Python
+```python
输入:people = [1,2], limit = 3
输出:1
解释:1 艘船载 (1, 2)
@@ -26,7 +26,7 @@
- 示例 2:
-```Python
+```python
输入:people = [3,2,2,1], limit = 3
输出:3
解释:3 艘船分别载 (1, 2), (2) 和 (3)
@@ -51,7 +51,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def numRescueBoats(self, people: List[int], limit: int) -> int:
people.sort()
diff --git "a/Solutions/0884. \344\270\244\345\217\245\350\257\235\344\270\255\347\232\204\344\270\215\345\270\270\350\247\201\345\215\225\350\257\215.md" "b/Solutions/0884. \344\270\244\345\217\245\350\257\235\344\270\255\347\232\204\344\270\215\345\270\270\350\247\201\345\215\225\350\257\215.md"
index 13eedbde..3cd7c522 100644
--- "a/Solutions/0884. \344\270\244\345\217\245\350\257\235\344\270\255\347\232\204\344\270\215\345\270\270\350\247\201\345\215\225\350\257\215.md"
+++ "b/Solutions/0884. \344\270\244\345\217\245\350\257\235\344\270\255\347\232\204\344\270\215\345\270\270\350\247\201\345\215\225\350\257\215.md"
@@ -23,14 +23,14 @@
- 示例 1:
-```Python
+```python
输入:s1 = "this apple is sweet", s2 = "this apple is sour"
输出:["sweet","sour"]
```
- 示例 2:
-```Python
+```python
输入:s1 = "apple apple", s2 = "banana"
输出:["banana"]
```
@@ -49,7 +49,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def uncommonFromSentences(self, s1: str, s2: str) -> List[str]:
table = dict()
diff --git "a/Solutions/0886. \345\217\257\350\203\275\347\232\204\344\272\214\345\210\206\346\263\225.md" "b/Solutions/0886. \345\217\257\350\203\275\347\232\204\344\272\214\345\210\206\346\263\225.md"
index 9ec70180..a165ac31 100644
--- "a/Solutions/0886. \345\217\257\350\203\275\347\232\204\344\272\214\345\210\206\346\263\225.md"
+++ "b/Solutions/0886. \345\217\257\350\203\275\347\232\204\344\272\214\345\210\206\346\263\225.md"
@@ -22,7 +22,7 @@
## 代码
-```Python
+```python
class Solution:
def dfs(self, graph, colors, i, color):
colors[i] = color
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 c72d9522..c3ebb86e 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"
@@ -22,7 +22,7 @@
- 示例 1:
-```Python
+```python
输入:k = 1, n = 2
输入:2
解释:鸡蛋从 1 楼掉落。如果它碎了,肯定能得出 f = 0。否则,鸡蛋从 2 楼掉落。如果它碎了,肯定能得出 f = 1。如果它没碎,那么肯定能得出 f = 2。因此,在最坏的情况下我们需要移动 2 次以确定 f 是多少。
@@ -117,7 +117,7 @@ $dp[i][j] = min_{1 \le x \le n} (max(dp[i - x][j], dp[x - 1][j - 1])) + 1$
### 思路 1:代码
-```Python
+```python
class Solution:
def superEggDrop(self, k: int, n: int) -> int:
dp = [[0 for _ in range(k + 1)] for i in range(n + 1)]
@@ -162,7 +162,7 @@ class Solution:
### 思路 2:代码
-```Python
+```python
class Solution:
def superEggDrop(self, k: int, n: int) -> int:
dp = [[0 for _ in range(k + 1)] for i in range(n + 1)]
@@ -236,7 +236,7 @@ class Solution:
### 思路 3:代码
-```Python
+```python
class Solution:
def superEggDrop(self, k: int, n: int) -> int:
dp = [[0 for _ in range(n + 1)] for i in range(k + 1)]
diff --git "a/Solutions/0889. \346\240\271\346\215\256\345\211\215\345\272\217\345\222\214\345\220\216\345\272\217\351\201\215\345\216\206\346\236\204\351\200\240\344\272\214\345\217\211\346\240\221.md" "b/Solutions/0889. \346\240\271\346\215\256\345\211\215\345\272\217\345\222\214\345\220\216\345\272\217\351\201\215\345\216\206\346\236\204\351\200\240\344\272\214\345\217\211\346\240\221.md"
index b0c196f3..ef6e60e6 100644
--- "a/Solutions/0889. \346\240\271\346\215\256\345\211\215\345\272\217\345\222\214\345\220\216\345\272\217\351\201\215\345\216\206\346\236\204\351\200\240\344\272\214\345\217\211\346\240\221.md"
+++ "b/Solutions/0889. \346\240\271\346\215\256\345\211\215\345\272\217\345\222\214\345\220\216\345\272\217\351\201\215\345\216\206\346\236\204\351\200\240\344\272\214\345\217\211\346\240\221.md"
@@ -25,14 +25,14 @@

-```Python
+```python
输入:preorder = [1,2,4,5,3,6,7], postorder = [4,5,2,6,7,3,1]
输出:[1,2,3,4,5,6,7]
```
- 示例 2:
-```Python
+```python
输入: preorder = [1], postorder = [1]
输出: [1]
```
@@ -59,7 +59,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def constructFromPrePost(self, preorder: List[int], postorder: List[int]) -> TreeNode:
def createTree(preorder, postorder, n):
diff --git "a/Solutions/0897. \351\200\222\345\242\236\351\241\272\345\272\217\346\220\234\347\264\242\346\240\221.md" "b/Solutions/0897. \351\200\222\345\242\236\351\241\272\345\272\217\346\220\234\347\264\242\346\240\221.md"
index 32c56d2d..d247017d 100644
--- "a/Solutions/0897. \351\200\222\345\242\236\351\241\272\345\272\217\346\220\234\347\264\242\346\240\221.md"
+++ "b/Solutions/0897. \351\200\222\345\242\236\351\241\272\345\272\217\346\220\234\347\264\242\346\240\221.md"
@@ -24,7 +24,7 @@
## 代码
-```Python
+```python
class Solution:
def inOrder(self, root, res):
if not root:
diff --git "a/Solutions/0901. \350\202\241\347\245\250\344\273\267\346\240\274\350\267\250\345\272\246.md" "b/Solutions/0901. \350\202\241\347\245\250\344\273\267\346\240\274\350\267\250\345\272\246.md"
index 705ab98f..7f1c2cc8 100644
--- "a/Solutions/0901. \350\202\241\347\245\250\344\273\267\346\240\274\350\267\250\345\272\246.md"
+++ "b/Solutions/0901. \350\202\241\347\245\250\344\273\267\346\240\274\350\267\250\345\272\246.md"
@@ -30,7 +30,7 @@
## 代码
-```Python
+```python
class StockSpanner:
def __init__(self):
diff --git "a/Solutions/0902. \346\234\200\345\244\247\344\270\272 N \347\232\204\346\225\260\345\255\227\347\273\204\345\220\210.md" "b/Solutions/0902. \346\234\200\345\244\247\344\270\272 N \347\232\204\346\225\260\345\255\227\347\273\204\345\220\210.md"
index a3590e8c..18021e54 100644
--- "a/Solutions/0902. \346\234\200\345\244\247\344\270\272 N \347\232\204\346\225\260\345\255\227\347\273\204\345\220\210.md"
+++ "b/Solutions/0902. \346\234\200\345\244\247\344\270\272 N \347\232\204\346\225\260\345\255\227\347\273\204\345\220\210.md"
@@ -22,7 +22,7 @@
- 示例 1:
-```Python
+```python
输入:digits = ["1","3","5","7"], n = 100
输出:20
解释:
@@ -32,7 +32,7 @@
- 示例 2:
-```Python
+```python
输入:digits = ["1","4","9"], n = 1000000000
输出:29523
解释:
@@ -72,7 +72,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def atMostNGivenDigitSet(self, digits: List[str], n: int) -> int:
# 将 n 转换为字符串 s
diff --git "a/Solutions/0904. \346\260\264\346\236\234\346\210\220\347\257\256.md" "b/Solutions/0904. \346\260\264\346\236\234\346\210\220\347\257\256.md"
index e2e78568..9dcf0110 100644
--- "a/Solutions/0904. \346\260\264\346\236\234\346\210\220\347\257\256.md"
+++ "b/Solutions/0904. \346\260\264\346\236\234\346\210\220\347\257\256.md"
@@ -30,7 +30,7 @@
## 代码
-```Python
+```python
class Solution:
def totalFruit(self, fruits: List[int]) -> int:
window = dict()
diff --git "a/Solutions/0908. \346\234\200\345\260\217\345\267\256\345\200\274 I.md" "b/Solutions/0908. \346\234\200\345\260\217\345\267\256\345\200\274 I.md"
index d3ed487d..54130626 100644
--- "a/Solutions/0908. \346\234\200\345\260\217\345\267\256\345\200\274 I.md"
+++ "b/Solutions/0908. \346\234\200\345\260\217\345\267\256\345\200\274 I.md"
@@ -19,7 +19,7 @@
- 示例 1:
-```Python
+```python
输入:nums = [1], k = 0
输出:0
解释:分数是 max(nums) - min(nums) = 1 - 1 = 0。
@@ -27,7 +27,7 @@
- 示例 2:
-```Python
+```python
输入:nums = [0,10], k = 2
输出:6
解释:将 nums 改为 [2,8]。分数是 max(nums) - min(nums) = 8 - 2 = 6。
@@ -41,7 +41,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def smallestRangeI(self, nums: List[int], k: int) -> int:
return max(0, max(nums) - min(nums) - 2*k)
diff --git "a/Solutions/0912. \346\216\222\345\272\217\346\225\260\347\273\204.md" "b/Solutions/0912. \346\216\222\345\272\217\346\225\260\347\273\204.md"
index 920f794c..4d141ef6 100644
--- "a/Solutions/0912. \346\216\222\345\272\217\346\225\260\347\273\204.md"
+++ "b/Solutions/0912. \346\216\222\345\272\217\346\225\260\347\273\204.md"
@@ -18,14 +18,14 @@
- 示例 1:
-```Python
+```python
输入:nums = [5,2,3,1]
输出:[1,2,3,5]
```
- 示例 2:
-```Python
+```python
输入:nums = [5,1,1,2,0,0]
输出:[0,0,1,1,2,5]
```
@@ -47,7 +47,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def bubbleSort(self, arr):
# 第 i 趟排序
@@ -79,7 +79,7 @@ class Solution:
### 思路 2:代码
-```Python
+```python
class Solution:
def selectionSort(self, arr):
for i in range(len(arr) - 1):
@@ -111,7 +111,7 @@ class Solution:
### 思路 3:代码
-```Python
+```python
class Solution:
def insertionSort(self, arr):
# 遍历无序序列
@@ -147,7 +147,7 @@ class Solution:
### 思路 4:代码
-```Python
+```python
class Solution:
def shellSort(self, arr):
size = len(arr)
@@ -188,7 +188,7 @@ class Solution:
### 思路 5:代码
-```Python
+```python
class Solution:
def merge(self, left_arr, right_arr): # 归并过程
arr = []
@@ -241,7 +241,7 @@ class Solution:
### 思路 6:代码
-```Python
+```python
import random
class Solution:
@@ -299,7 +299,7 @@ class Solution:
### 思路 7:代码
-```Python
+```python
class Solution:
# 调整为大顶堆
def heapify(self, arr, index, end):
@@ -360,7 +360,7 @@ class Solution:
### 思路 8:代码
-```Python
+```python
class Solution:
def countingSort(self, arr):
# 计算待排序序列中最大值元素 arr_max 和最小值元素 arr_min
@@ -404,7 +404,7 @@ class Solution:
### 思路 9:代码
-```Python
+```python
class Solution:
def insertionSort(self, arr):
# 遍历无序序列
@@ -458,7 +458,7 @@ class Solution:
### 思路 10:代码
-```Python
+```python
class Solution:
def radixSort(self, arr):
# 桶的大小为所有元素的最大位数
diff --git "a/Solutions/0918. \347\216\257\345\275\242\345\255\220\346\225\260\347\273\204\347\232\204\346\234\200\345\244\247\345\222\214.md" "b/Solutions/0918. \347\216\257\345\275\242\345\255\220\346\225\260\347\273\204\347\232\204\346\234\200\345\244\247\345\222\214.md"
index 7c5f728b..5846d299 100644
--- "a/Solutions/0918. \347\216\257\345\275\242\345\255\220\346\225\260\347\273\204\347\232\204\346\234\200\345\244\247\345\222\214.md"
+++ "b/Solutions/0918. \347\216\257\345\275\242\345\255\220\346\225\260\347\273\204\347\232\204\346\234\200\345\244\247\345\222\214.md"
@@ -26,7 +26,7 @@
## 代码
-```Python
+```python
class Solution:
def maxSubarraySumCircular(self, nums: List[int]) -> int:
size = len(nums)
diff --git "a/Solutions/0919. \345\256\214\345\205\250\344\272\214\345\217\211\346\240\221\346\217\222\345\205\245\345\231\250.md" "b/Solutions/0919. \345\256\214\345\205\250\344\272\214\345\217\211\346\240\221\346\217\222\345\205\245\345\231\250.md"
index b38b8248..49ced4d9 100644
--- "a/Solutions/0919. \345\256\214\345\205\250\344\272\214\345\217\211\346\240\221\346\217\222\345\205\245\345\231\250.md"
+++ "b/Solutions/0919. \345\256\214\345\205\250\344\272\214\345\217\211\346\240\221\346\217\222\345\205\245\345\231\250.md"
@@ -19,7 +19,7 @@
## 代码
-```Python
+```python
class CBTInserter:
def __init__(self, root: TreeNode):
diff --git "a/Solutions/0921. \344\275\277\346\213\254\345\217\267\346\234\211\346\225\210\347\232\204\346\234\200\345\260\221\346\267\273\345\212\240.md" "b/Solutions/0921. \344\275\277\346\213\254\345\217\267\346\234\211\346\225\210\347\232\204\346\234\200\345\260\221\346\267\273\345\212\240.md"
index cfd943f1..30ecc6b7 100644
--- "a/Solutions/0921. \344\275\277\346\213\254\345\217\267\346\234\211\346\225\210\347\232\204\346\234\200\345\260\221\346\267\273\345\212\240.md"
+++ "b/Solutions/0921. \344\275\277\346\213\254\345\217\267\346\234\211\346\225\210\347\232\204\346\234\200\345\260\221\346\267\273\345\212\240.md"
@@ -26,7 +26,7 @@
- 示例 1:
-```Python
+```python
输入:s = "())"
输出:1
```
@@ -47,7 +47,7 @@
### 思路 1:贪心算法代码
-```Python
+```python
class Solution:
def minAddToMakeValid(self, s: str) -> int:
res = 0
diff --git "a/Solutions/0925. \351\225\277\346\214\211\351\224\256\345\205\245.md" "b/Solutions/0925. \351\225\277\346\214\211\351\224\256\345\205\245.md"
index 437ef648..f6e3f5d6 100644
--- "a/Solutions/0925. \351\225\277\346\214\211\351\224\256\345\205\245.md"
+++ "b/Solutions/0925. \351\225\277\346\214\211\351\224\256\345\205\245.md"
@@ -25,7 +25,7 @@
## 代码
-```Python
+```python
class Solution:
def isLongPressedName(self, name: str, typed: str) -> bool:
left_1, left_2 = 0, 0
diff --git "a/Solutions/0932. \346\274\202\344\272\256\346\225\260\347\273\204.md" "b/Solutions/0932. \346\274\202\344\272\256\346\225\260\347\273\204.md"
index 13b4d40e..9c99e7a7 100644
--- "a/Solutions/0932. \346\274\202\344\272\256\346\225\260\347\273\204.md"
+++ "b/Solutions/0932. \346\274\202\344\272\256\346\225\260\347\273\204.md"
@@ -21,14 +21,14 @@
- 示例 1:
-```Python
+```python
输入:n = 4
输出:[2,1,4,3]
```
- 示例 2:
-```Python
+```python
输入:n = 5
输出:[3,1,2,5,4]
```
@@ -55,7 +55,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def beautifulArray(self, n: int) -> List[int]:
if n == 1:
diff --git "a/Solutions/0933. \346\234\200\350\277\221\347\232\204\350\257\267\346\261\202\346\254\241\346\225\260.md" "b/Solutions/0933. \346\234\200\350\277\221\347\232\204\350\257\267\346\261\202\346\254\241\346\225\260.md"
index 71486fb7..3578a7b0 100644
--- "a/Solutions/0933. \346\234\200\350\277\221\347\232\204\350\257\267\346\261\202\346\254\241\346\225\260.md"
+++ "b/Solutions/0933. \346\234\200\350\277\221\347\232\204\350\257\267\346\261\202\346\254\241\346\225\260.md"
@@ -18,7 +18,7 @@
## 代码
-```Python
+```python
class RecentCounter:
def __init__(self):
diff --git "a/Solutions/0935. \351\252\221\345\243\253\346\213\250\345\217\267\345\231\250.md" "b/Solutions/0935. \351\252\221\345\243\253\346\213\250\345\217\267\345\231\250.md"
index b77b1209..9b20ed21 100644
--- "a/Solutions/0935. \351\252\221\345\243\253\346\213\250\345\217\267\345\231\250.md"
+++ "b/Solutions/0935. \351\252\221\345\243\253\346\213\250\345\217\267\345\231\250.md"
@@ -26,7 +26,7 @@
- 示例 1:
-```Python
+```python
输入:n = 1
输出:10
解释:我们需要拨一个长度为1的数字,所以把骑士放在10个单元格中的任何一个数字单元格上都能满足条件。
@@ -34,7 +34,7 @@
- 示例 2:
-```Python
+```python
输入:n = 2
输出:20
解释:我们可以拨打的所有有效号码为[04, 06, 16, 18, 27, 29, 34, 38, 40, 43, 49, 60, 61, 67, 72, 76, 81, 83, 92, 94]
@@ -72,7 +72,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def knightDialer(self, n: int) -> int:
graph = {
diff --git "a/Solutions/0938. \344\272\214\345\217\211\346\220\234\347\264\242\346\240\221\347\232\204\350\214\203\345\233\264\345\222\214.md" "b/Solutions/0938. \344\272\214\345\217\211\346\220\234\347\264\242\346\240\221\347\232\204\350\214\203\345\233\264\345\222\214.md"
index e5b629ff..6c4a5e37 100644
--- "a/Solutions/0938. \344\272\214\345\217\211\346\220\234\347\264\242\346\240\221\347\232\204\350\214\203\345\233\264\345\222\214.md"
+++ "b/Solutions/0938. \344\272\214\345\217\211\346\220\234\347\264\242\346\240\221\347\232\204\350\214\203\345\233\264\345\222\214.md"
@@ -24,7 +24,7 @@
## 代码
-```Python
+```python
class Solution:
def rangeSumBST(self, root: TreeNode, low: int, high: int) -> int:
if not root:
diff --git "a/Solutions/0946. \351\252\214\350\257\201\346\240\210\345\272\217\345\210\227.md" "b/Solutions/0946. \351\252\214\350\257\201\346\240\210\345\272\217\345\210\227.md"
index c5368ab7..b089a4df 100644
--- "a/Solutions/0946. \351\252\214\350\257\201\346\240\210\345\272\217\345\210\227.md"
+++ "b/Solutions/0946. \351\252\214\350\257\201\346\240\210\345\272\217\345\210\227.md"
@@ -21,7 +21,7 @@
- 示例 1:
-```Python
+```python
输入:pushed = [1,2,3,4,5], popped = [4,5,3,2,1]
输出:true
解释:我们可以按以下顺序执行:
@@ -31,7 +31,7 @@ push(5), pop() -> 5, pop() -> 3, pop() -> 2, pop() -> 1
- 示例 2:
-```Python
+```python
输入:pushed = [1,2,3,4,5], popped = [4,3,5,1,2]
输出:false
解释:1 不能在 2 之前弹出。
@@ -45,7 +45,7 @@ push(5), pop() -> 5, pop() -> 3, pop() -> 2, pop() -> 1
### 思路 1:代码
-```Python
+```python
class Solution:
def validateStackSequences(self, pushed: List[int], popped: List[int]) -> bool:
stack = []
diff --git "a/Solutions/0947. \347\247\273\351\231\244\346\234\200\345\244\232\347\232\204\345\220\214\350\241\214\346\210\226\345\220\214\345\210\227\347\237\263\345\244\264.md" "b/Solutions/0947. \347\247\273\351\231\244\346\234\200\345\244\232\347\232\204\345\220\214\350\241\214\346\210\226\345\220\214\345\210\227\347\237\263\345\244\264.md"
index 945b0b48..c101339d 100644
--- "a/Solutions/0947. \347\247\273\351\231\244\346\234\200\345\244\232\347\232\204\345\220\214\350\241\214\346\210\226\345\220\214\345\210\227\347\237\263\345\244\264.md"
+++ "b/Solutions/0947. \347\247\273\351\231\244\346\234\200\345\244\232\347\232\204\345\220\214\350\241\214\346\210\226\345\220\214\345\210\227\347\237\263\345\244\264.md"
@@ -21,7 +21,7 @@
- 示例 1:
-```Python
+```python
输入:stones = [[0,0],[0,1],[1,0],[1,2],[2,1],[2,2]]
输出:5
解释:一种移除 5 块石头的方法如下所示:
@@ -35,7 +35,7 @@
- 示例 2:
-```Python
+```python
输入:stones = [[0,0],[0,2],[1,1],[2,0],[2,2]]
输出:3
解释:一种移除 3 块石头的方法如下所示:
@@ -74,7 +74,7 @@
### 思路 1:代码
-```Python
+```python
class UnionFind:
def __init__(self, n):
diff --git "a/Solutions/0953. \351\252\214\350\257\201\345\244\226\346\230\237\350\257\255\350\257\215\345\205\270.md" "b/Solutions/0953. \351\252\214\350\257\201\345\244\226\346\230\237\350\257\255\350\257\215\345\205\270.md"
index aacda57d..6cd0bb9e 100644
--- "a/Solutions/0953. \351\252\214\350\257\201\345\244\226\346\230\237\350\257\255\350\257\215\345\205\270.md"
+++ "b/Solutions/0953. \351\252\214\350\257\201\345\244\226\346\230\237\350\257\255\350\257\215\345\205\270.md"
@@ -19,7 +19,7 @@
## 代码
-```Python
+```python
class Solution:
def isAlienSorted(self, words: List[str], order: str) -> bool:
order_map = dict()
diff --git "a/Solutions/0958. \344\272\214\345\217\211\346\240\221\347\232\204\345\256\214\345\205\250\346\200\247\346\243\200\351\252\214.md" "b/Solutions/0958. \344\272\214\345\217\211\346\240\221\347\232\204\345\256\214\345\205\250\346\200\247\346\243\200\351\252\214.md"
index 29d4919e..644892ec 100644
--- "a/Solutions/0958. \344\272\214\345\217\211\346\240\221\347\232\204\345\256\214\345\205\250\346\200\247\346\243\200\351\252\214.md"
+++ "b/Solutions/0958. \344\272\214\345\217\211\346\240\221\347\232\204\345\256\214\345\205\250\346\200\247\346\243\200\351\252\214.md"
@@ -21,7 +21,7 @@

-```Python
+```python
输入:root = [1,2,3,4,5,6]
输出:true
解释:最后一层前的每一层都是满的(即,结点值为 {1} 和 {2,3} 的两层),且最后一层中的所有结点({4,5,6})都尽可能地向左。
@@ -31,7 +31,7 @@

-```Python
+```python
输入:root = [1,2,3,4,5,null,7]
输出:false
解释:值为 7 的结点没有尽可能靠向左侧。
@@ -49,7 +49,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def isCompleteTree(self, root: Optional[TreeNode]) -> bool:
if not root:
diff --git "a/Solutions/0959. \347\224\261\346\226\234\346\235\240\345\210\222\345\210\206\345\214\272\345\237\237.md" "b/Solutions/0959. \347\224\261\346\226\234\346\235\240\345\210\222\345\210\206\345\214\272\345\237\237.md"
index 532af3f5..1c9a60cc 100644
--- "a/Solutions/0959. \347\224\261\346\226\234\346\235\240\345\210\222\345\210\206\345\214\272\345\237\237.md"
+++ "b/Solutions/0959. \347\224\261\346\226\234\346\235\240\345\210\222\345\210\206\345\214\272\345\237\237.md"
@@ -39,7 +39,7 @@
## 代码
-```Python
+```python
class UnionFind:
def __init__(self, n):
diff --git "a/Solutions/0968. \347\233\221\346\216\247\344\272\214\345\217\211\346\240\221.md" "b/Solutions/0968. \347\233\221\346\216\247\344\272\214\345\217\211\346\240\221.md"
index f9293b03..cd0269f5 100644
--- "a/Solutions/0968. \347\233\221\346\216\247\344\272\214\345\217\211\346\240\221.md"
+++ "b/Solutions/0968. \347\233\221\346\216\247\344\272\214\345\217\211\346\240\221.md"
@@ -55,7 +55,7 @@
## 代码
-```Python
+```python
class Solution:
res = 0
def traversal(self, cur: TreeNode) -> int:
diff --git "a/Solutions/0973. \346\234\200\346\216\245\350\277\221\345\216\237\347\202\271\347\232\204 K \344\270\252\347\202\271.md" "b/Solutions/0973. \346\234\200\346\216\245\350\277\221\345\216\237\347\202\271\347\232\204 K \344\270\252\347\202\271.md"
index 299993eb..b6363d2b 100644
--- "a/Solutions/0973. \346\234\200\346\216\245\350\277\221\345\216\237\347\202\271\347\232\204 K \344\270\252\347\202\271.md"
+++ "b/Solutions/0973. \346\234\200\346\216\245\350\277\221\345\216\237\347\202\271\347\232\204 K \344\270\252\347\202\271.md"
@@ -18,7 +18,7 @@
## 代码
-```Python
+```python
class Heapq:
def compare(self, a, b):
dist_a = a[0] * a[0] + a[1] * a[1]
diff --git "a/Solutions/0974. \345\222\214\345\217\257\350\242\253 K \346\225\264\351\231\244\347\232\204\345\255\220\346\225\260\347\273\204.md" "b/Solutions/0974. \345\222\214\345\217\257\350\242\253 K \346\225\264\351\231\244\347\232\204\345\255\220\346\225\260\347\273\204.md"
index 529b3304..37176f61 100644
--- "a/Solutions/0974. \345\222\214\345\217\257\350\242\253 K \346\225\264\351\231\244\347\232\204\345\255\220\346\225\260\347\273\204.md"
+++ "b/Solutions/0974. \345\222\214\345\217\257\350\242\253 K \346\225\264\351\231\244\347\232\204\345\255\220\346\225\260\347\273\204.md"
@@ -13,7 +13,7 @@
先考虑暴力计算子数组和,外层两重循环,遍历所有连续子数组,然后最内层再计算一下子数组的和。部分代码如下:
-```Python
+```python
for i in range(len(nums)):
for j in range(i + 1):
sum = countSum(i, j)
@@ -38,7 +38,7 @@ for i in range(len(nums)):
## 代码
-```Python
+```python
class Solution:
def subarraysDivByK(self, nums: List[int], k: int) -> int:
pre_sum = 0
diff --git "a/Solutions/0976. \344\270\211\350\247\222\345\275\242\347\232\204\346\234\200\345\244\247\345\221\250\351\225\277.md" "b/Solutions/0976. \344\270\211\350\247\222\345\275\242\347\232\204\346\234\200\345\244\247\345\221\250\351\225\277.md"
index a3b52464..aff797be 100644
--- "a/Solutions/0976. \344\270\211\350\247\222\345\275\242\347\232\204\346\234\200\345\244\247\345\221\250\351\225\277.md"
+++ "b/Solutions/0976. \344\270\211\350\247\222\345\275\242\347\232\204\346\234\200\345\244\247\345\221\250\351\225\277.md"
@@ -18,7 +18,7 @@
- 示例 1:
-```Python
+```python
输入:nums = [2,1,2]
输出:5
解释:长度为 2, 1, 2 的边组成的三角形周长为 5,为最大周长
@@ -36,7 +36,7 @@
### 思路 1 代码:
-```Python
+```python
class Solution:
def largestPerimeter(self, nums: List[int]) -> int:
nums.sort()
diff --git "a/Solutions/0977. \346\234\211\345\272\217\346\225\260\347\273\204\347\232\204\345\271\263\346\226\271.md" "b/Solutions/0977. \346\234\211\345\272\217\346\225\260\347\273\204\347\232\204\345\271\263\346\226\271.md"
index 467a7703..ede1cb29 100644
--- "a/Solutions/0977. \346\234\211\345\272\217\346\225\260\347\273\204\347\232\204\345\271\263\346\226\271.md"
+++ "b/Solutions/0977. \346\234\211\345\272\217\346\225\260\347\273\204\347\232\204\345\271\263\346\226\271.md"
@@ -42,7 +42,7 @@
- 双指针:
-```Python
+```python
class Solution:
def sortedSquares(self, nums: List[int]) -> List[int]:
size = len(nums)
@@ -65,7 +65,7 @@ class Solution:
- 排序算法
-```Python
+```python
import random
class Solution:
diff --git "a/Solutions/0978. \346\234\200\351\225\277\346\271\215\346\265\201\345\255\220\346\225\260\347\273\204.md" "b/Solutions/0978. \346\234\200\351\225\277\346\271\215\346\265\201\345\255\220\346\225\260\347\273\204.md"
index c0db8c9a..6a5a55b1 100644
--- "a/Solutions/0978. \346\234\200\351\225\277\346\271\215\346\265\201\345\255\220\346\225\260\347\273\204.md"
+++ "b/Solutions/0978. \346\234\200\351\225\277\346\271\215\346\265\201\345\255\220\346\225\260\347\273\204.md"
@@ -26,7 +26,7 @@
## 代码
-```Python
+```python
class Solution:
def maxTurbulenceSize(self, arr: List[int]) -> int:
left, right = 0, 1
diff --git "a/Solutions/0982. \346\214\211\344\275\215\344\270\216\344\270\272\351\233\266\347\232\204\344\270\211\345\205\203\347\273\204.md" "b/Solutions/0982. \346\214\211\344\275\215\344\270\216\344\270\272\351\233\266\347\232\204\344\270\211\345\205\203\347\273\204.md"
index 28978ff1..a3c4caa3 100644
--- "a/Solutions/0982. \346\214\211\344\275\215\344\270\216\344\270\272\351\233\266\347\232\204\344\270\211\345\205\203\347\273\204.md"
+++ "b/Solutions/0982. \346\214\211\344\275\215\344\270\216\344\270\272\351\233\266\347\232\204\344\270\211\345\205\203\347\273\204.md"
@@ -24,7 +24,7 @@
- 示例 1:
-```Python
+```python
输入:nums = [2,1,3]
输出:12
解释:可以选出如下 i, j, k 三元组:
@@ -44,7 +44,7 @@
- 示例 2:
-```Python
+```python
输入:nums = [0,0,0]
输出:27
```
@@ -63,7 +63,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def countTriplets(self, nums: List[int]) -> int:
states = 1 << 16
@@ -119,7 +119,7 @@ class Solution:
### 思路 2:代码
-```Python
+```python
class Solution:
def countTriplets(self, nums: List[int]) -> int:
states = 1 << 16
diff --git "a/Solutions/0990. \347\255\211\345\274\217\346\226\271\347\250\213\347\232\204\345\217\257\346\273\241\350\266\263\346\200\247.md" "b/Solutions/0990. \347\255\211\345\274\217\346\226\271\347\250\213\347\232\204\345\217\257\346\273\241\350\266\263\346\200\247.md"
index 1913f983..71aeff51 100644
--- "a/Solutions/0990. \347\255\211\345\274\217\346\226\271\347\250\213\347\232\204\345\217\257\346\273\241\350\266\263\346\200\247.md"
+++ "b/Solutions/0990. \347\255\211\345\274\217\346\226\271\347\250\213\347\232\204\345\217\257\346\273\241\350\266\263\346\200\247.md"
@@ -21,7 +21,7 @@
- 示例 1:
-```Python
+```python
输入:["a==b","b!=a"]
输出:False
解释:如果我们指定,a = 1 且 b = 1,那么可以满足第一个方程,但无法满足第二个方程。没有办法分配变量同时满足这两个方程。
@@ -40,7 +40,7 @@
### 思路 1:并查集代码
-```Python
+```python
class UnionFind:
def __init__(self, n): # 初始化
self.fa = [i for i in range(n)] # 每个元素的集合编号初始化为数组 fa 的下标索引
diff --git "a/Solutions/0992. K \344\270\252\344\270\215\345\220\214\346\225\264\346\225\260\347\232\204\345\255\220\346\225\260\347\273\204.md" "b/Solutions/0992. K \344\270\252\344\270\215\345\220\214\346\225\264\346\225\260\347\232\204\345\255\220\346\225\260\347\273\204.md"
index 6affbc9f..6d187b3e 100644
--- "a/Solutions/0992. K \344\270\252\344\270\215\345\220\214\346\225\264\346\225\260\347\232\204\345\255\220\346\225\260\347\273\204.md"
+++ "b/Solutions/0992. K \344\270\252\344\270\215\345\220\214\346\225\264\346\225\260\347\232\204\345\255\220\346\225\260\347\273\204.md"
@@ -34,7 +34,7 @@
## 代码
-```Python
+```python
class Solution:
def subarraysMostKDistinct(self, nums, k):
windows = dict()
diff --git "a/Solutions/0993. \344\272\214\345\217\211\346\240\221\347\232\204\345\240\202\345\205\204\345\274\237\350\212\202\347\202\271.md" "b/Solutions/0993. \344\272\214\345\217\211\346\240\221\347\232\204\345\240\202\345\205\204\345\274\237\350\212\202\347\202\271.md"
index 6aa4560f..8d9e7bc6 100644
--- "a/Solutions/0993. \344\272\214\345\217\211\346\240\221\347\232\204\345\240\202\345\205\204\345\274\237\350\212\202\347\202\271.md"
+++ "b/Solutions/0993. \344\272\214\345\217\211\346\240\221\347\232\204\345\240\202\345\205\204\345\274\237\350\212\202\347\202\271.md"
@@ -15,7 +15,7 @@
## 代码
-```Python
+```python
class Solution:
def isCousins(self, root: TreeNode, x: int, y: int) -> bool:
depths = [0, 0]
diff --git "a/Solutions/0995. K \350\277\236\347\273\255\344\275\215\347\232\204\346\234\200\345\260\217\347\277\273\350\275\254\346\254\241\346\225\260.md" "b/Solutions/0995. K \350\277\236\347\273\255\344\275\215\347\232\204\346\234\200\345\260\217\347\277\273\350\275\254\346\254\241\346\225\260.md"
index 49193626..f14dde3f 100644
--- "a/Solutions/0995. K \350\277\236\347\273\255\344\275\215\347\232\204\346\234\200\345\260\217\347\277\273\350\275\254\346\254\241\346\225\260.md"
+++ "b/Solutions/0995. K \350\277\236\347\273\255\344\275\215\347\232\204\346\234\200\345\260\217\347\277\273\350\275\254\346\254\241\346\225\260.md"
@@ -41,7 +41,7 @@
## 代码
-```Python
+```python
class Solution:
def minKBitFlips(self, nums: List[int], k: int) -> int:
ans = 0
diff --git "a/Solutions/1000. \345\220\210\345\271\266\347\237\263\345\244\264\347\232\204\346\234\200\344\275\216\346\210\220\346\234\254.md" "b/Solutions/1000. \345\220\210\345\271\266\347\237\263\345\244\264\347\232\204\346\234\200\344\275\216\346\210\220\346\234\254.md"
index 084cd6bb..192acf44 100644
--- "a/Solutions/1000. \345\220\210\345\271\266\347\237\263\345\244\264\347\232\204\346\234\200\344\275\216\346\210\220\346\234\254.md"
+++ "b/Solutions/1000. \345\220\210\345\271\266\347\237\263\345\244\264\347\232\204\346\234\200\344\275\216\346\210\220\346\234\254.md"
@@ -20,7 +20,7 @@
- 示例 1:
-```Python
+```python
输入:stones = [3,2,4,1], K = 2
输出:20
解释:
@@ -33,7 +33,7 @@
- 示例 2:
-```Python
+```python
输入:stones = [3,5,1,2,6], K = 3
输出:25
解释:
@@ -84,7 +84,7 @@ $k$ 堆石头合并为 $1$ 堆石头的过程,可以看做是长度为 $k$ 的
### 思路 1:代码
-```Python
+```python
class Solution:
def mergeStones(self, stones: List[int], k: int) -> int:
size = len(stones)
@@ -154,7 +154,7 @@ $dp[i][j] = min_{i \le n < j} \lbrace dp[i][n] + dp[n + 1][j] \rbrace$。
### 思路 2:代码
-```Python
+```python
class Solution:
def mergeStones(self, stones: List[int], k: int) -> int:
size = len(stones)
diff --git "a/Solutions/1002. \346\237\245\346\211\276\345\205\261\347\224\250\345\255\227\347\254\246.md" "b/Solutions/1002. \346\237\245\346\211\276\345\205\261\347\224\250\345\255\227\347\254\246.md"
index c01af93a..93a235eb 100644
--- "a/Solutions/1002. \346\237\245\346\211\276\345\205\261\347\224\250\345\255\227\347\254\246.md"
+++ "b/Solutions/1002. \346\237\245\346\211\276\345\205\261\347\224\250\345\255\227\347\254\246.md"
@@ -19,14 +19,14 @@
- 示例 1:
-```Python
+```python
输入:words = ["bella","label","roller"]
输出:["e","l","l"]
```
- 示例 2:
-```Python
+```python
输入:words = ["cool","lock","cook"]
输出:["c","o"]
```
@@ -46,7 +46,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def commonChars(self, words: List[str]) -> List[str]:
minfreq = [float('inf') for _ in range(26)]
diff --git "a/Solutions/1004. \346\234\200\345\244\247\350\277\236\347\273\2551\347\232\204\344\270\252\346\225\260 III.md" "b/Solutions/1004. \346\234\200\345\244\247\350\277\236\347\273\2551\347\232\204\344\270\252\346\225\260 III.md"
index db48bbc2..ae92637e 100644
--- "a/Solutions/1004. \346\234\200\345\244\247\350\277\236\347\273\2551\347\232\204\344\270\252\346\225\260 III.md"
+++ "b/Solutions/1004. \346\234\200\345\244\247\350\277\236\347\273\2551\347\232\204\344\270\252\346\225\260 III.md"
@@ -19,7 +19,7 @@
- 示例 1:
-```Python
+```python
输入:nums = [1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0], K = 2
输出:6
解释:[1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1]
@@ -43,7 +43,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def longestOnes(self, nums: List[int], k: int) -> int:
max_count = 0
diff --git "a/Solutions/1005. K \346\254\241\345\217\226\345\217\215\345\220\216\346\234\200\345\244\247\345\214\226\347\232\204\346\225\260\347\273\204\345\222\214.md" "b/Solutions/1005. K \346\254\241\345\217\226\345\217\215\345\220\216\346\234\200\345\244\247\345\214\226\347\232\204\346\225\260\347\273\204\345\222\214.md"
index 399aa5b1..757da097 100644
--- "a/Solutions/1005. K \346\254\241\345\217\226\345\217\215\345\220\216\346\234\200\345\244\247\345\214\226\347\232\204\346\225\260\347\273\204\345\222\214.md"
+++ "b/Solutions/1005. K \346\254\241\345\217\226\345\217\215\345\220\216\346\234\200\345\244\247\345\214\226\347\232\204\346\225\260\347\273\204\345\222\214.md"
@@ -23,7 +23,7 @@
## 代码
-```Python
+```python
class Solution:
def largestSumAfterKNegations(self, nums: List[int], k: int) -> int:
nums.sort(key=lambda x: abs(x), reverse = True)
diff --git "a/Solutions/1008. \345\211\215\345\272\217\351\201\215\345\216\206\346\236\204\351\200\240\344\272\214\345\217\211\346\220\234\347\264\242\346\240\221.md" "b/Solutions/1008. \345\211\215\345\272\217\351\201\215\345\216\206\346\236\204\351\200\240\344\272\214\345\217\211\346\220\234\347\264\242\346\240\221.md"
index 4ee0ef4a..d6e9a7e8 100644
--- "a/Solutions/1008. \345\211\215\345\272\217\351\201\215\345\216\206\346\236\204\351\200\240\344\272\214\345\217\211\346\220\234\347\264\242\346\240\221.md"
+++ "b/Solutions/1008. \345\211\215\345\272\217\351\201\215\345\216\206\346\236\204\351\200\240\344\272\214\345\217\211\346\220\234\347\264\242\346\240\221.md"
@@ -23,7 +23,7 @@
## 代码
-```Python
+```python
class Solution:
def buildTree(self, preorder, start, end):
if start == end:
diff --git "a/Solutions/1009. \345\215\201\350\277\233\345\210\266\346\225\264\346\225\260\347\232\204\345\217\215\347\240\201.md" "b/Solutions/1009. \345\215\201\350\277\233\345\210\266\346\225\264\346\225\260\347\232\204\345\217\215\347\240\201.md"
index 929d2f12..a082410f 100644
--- "a/Solutions/1009. \345\215\201\350\277\233\345\210\266\346\225\264\346\225\260\347\232\204\345\217\215\347\240\201.md"
+++ "b/Solutions/1009. \345\215\201\350\277\233\345\210\266\346\225\264\346\225\260\347\232\204\345\217\215\347\240\201.md"
@@ -17,7 +17,7 @@
- 示例 1:
-```Python
+```python
输入:5
输出:2
解释:5 的二进制表示为 "101",其二进制反码为 "010",也就是十进制中的 2 。
@@ -25,7 +25,7 @@
- 示例 2:
-```Python
+```python
输入:7
输出:0
解释:7 的二进制表示为 "111",其二进制反码为 "000",也就是十进制中的 0 。
@@ -43,7 +43,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def bitwiseComplement(self, n: int) -> int:
binary = ""
diff --git "a/Solutions/1011. \345\234\250 D \345\244\251\345\206\205\351\200\201\350\276\276\345\214\205\350\243\271\347\232\204\350\203\275\345\212\233.md" "b/Solutions/1011. \345\234\250 D \345\244\251\345\206\205\351\200\201\350\276\276\345\214\205\350\243\271\347\232\204\350\203\275\345\212\233.md"
index e3c82da4..f04d7854 100644
--- "a/Solutions/1011. \345\234\250 D \345\244\251\345\206\205\351\200\201\350\276\276\345\214\205\350\243\271\347\232\204\350\203\275\345\212\233.md"
+++ "b/Solutions/1011. \345\234\250 D \345\244\251\345\206\205\351\200\201\350\276\276\345\214\205\350\243\271\347\232\204\350\203\275\345\212\233.md"
@@ -18,7 +18,7 @@
- 示例 1:
-```Python
+```python
输入:weights = [1,2,3,4,5,6,7,8,9,10], days = 5
输出:15
解释:
@@ -33,7 +33,7 @@
- 示例 2:
-```Python
+```python
输入:weights = [3,2,2,4,1,4], days = 3
输出:6
解释:
@@ -55,7 +55,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def shipWithinDays(self, weights: List[int], D: int) -> int:
left = max(weights)
diff --git "a/Solutions/1012. \350\207\263\345\260\221\346\234\211 1 \344\275\215\351\207\215\345\244\215\347\232\204\346\225\260\345\255\227.md" "b/Solutions/1012. \350\207\263\345\260\221\346\234\211 1 \344\275\215\351\207\215\345\244\215\347\232\204\346\225\260\345\255\227.md"
index 35e09c87..22338620 100644
--- "a/Solutions/1012. \350\207\263\345\260\221\346\234\211 1 \344\275\215\351\207\215\345\244\215\347\232\204\346\225\260\345\255\227.md"
+++ "b/Solutions/1012. \350\207\263\345\260\221\346\234\211 1 \344\275\215\351\207\215\345\244\215\347\232\204\346\225\260\345\255\227.md"
@@ -17,7 +17,7 @@
- 示例 1:
-```Python
+```python
输入:n = 20
输出:1
解释:具有至少 1 位重复数字的正数(<= 20)只有 11。
@@ -25,7 +25,7 @@
- 示例 2:
-```Python
+```python
输入:n = 100
输出:10
解释:具有至少 1 位重复数字的正数(<= 100)有 11,22,33,44,55,66,77,88,99 和 100。
@@ -60,7 +60,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def numDupDigitsAtMostN(self, n: int) -> int:
# 将 n 转换为字符串 s
diff --git "a/Solutions/1014. \346\234\200\344\275\263\350\247\202\345\205\211\347\273\204\345\220\210.md" "b/Solutions/1014. \346\234\200\344\275\263\350\247\202\345\205\211\347\273\204\345\220\210.md"
index 5968fa45..74760419 100644
--- "a/Solutions/1014. \346\234\200\344\275\263\350\247\202\345\205\211\347\273\204\345\220\210.md"
+++ "b/Solutions/1014. \346\234\200\344\275\263\350\247\202\345\205\211\347\273\204\345\220\210.md"
@@ -15,7 +15,7 @@
## 代码
-```Python
+```python
class Solution:
def maxScoreSightseeingPair(self, values: List[int]) -> int:
ans = 0
diff --git "a/Solutions/1020. \351\243\236\345\234\260\347\232\204\346\225\260\351\207\217.md" "b/Solutions/1020. \351\243\236\345\234\260\347\232\204\346\225\260\351\207\217.md"
index 7f53af98..0eaa0ce6 100644
--- "a/Solutions/1020. \351\243\236\345\234\260\347\232\204\346\225\260\351\207\217.md"
+++ "b/Solutions/1020. \351\243\236\345\234\260\347\232\204\346\225\260\351\207\217.md"
@@ -22,7 +22,7 @@

-```Python
+```python
输入:grid = [[0,0,0,0],[1,0,1,0],[0,1,1,0],[0,0,0,0]]
输出:3
解释:有三个 1 被 0 包围。一个 1 没有被包围,因为它在边界上。
@@ -32,7 +32,7 @@

-```Python
+```python
输入:grid = [[0,1,1,0],[0,0,1,0],[0,0,1,0],[0,0,0,0]]
输出:0
解释:所有 1 都在边界上或可以到达边界。
@@ -50,7 +50,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
directs = [(0, 1), (0, -1), (1, 0), (-1, 0)]
diff --git "a/Solutions/1023. \351\251\274\345\263\260\345\274\217\345\214\271\351\205\215.md" "b/Solutions/1023. \351\251\274\345\263\260\345\274\217\345\214\271\351\205\215.md"
index 08dd9ecc..0e1a1b70 100644
--- "a/Solutions/1023. \351\251\274\345\263\260\345\274\217\345\214\271\351\205\215.md"
+++ "b/Solutions/1023. \351\251\274\345\263\260\345\274\217\345\214\271\351\205\215.md"
@@ -20,7 +20,7 @@
- 示例 1:
-```Python
+```python
输入:queries = ["FooBar","FooBarTest","FootBall","FrameBuffer","ForceFeedBack"], pattern = "FB"
输出:[true,false,true,true,false]
示例:
@@ -31,7 +31,7 @@
- 示例 2:
-```Python
+```python
输入:queries = ["FooBar","FooBarTest","FootBall","FrameBuffer","ForceFeedBack"], pattern = "FoBa"
输出:[true,false,true,false,false]
解释:
@@ -54,7 +54,7 @@
### 思路 1:代码
-```Python
+```python
class Trie:
def __init__(self):
diff --git "a/Solutions/1025. \351\231\244\346\225\260\345\215\232\345\274\210.md" "b/Solutions/1025. \351\231\244\346\225\260\345\215\232\345\274\210.md"
index e5af6ddc..300dc2bd 100644
--- "a/Solutions/1025. \351\231\244\346\225\260\345\215\232\345\274\210.md"
+++ "b/Solutions/1025. \351\231\244\346\225\260\345\215\232\345\274\210.md"
@@ -25,7 +25,7 @@
## 代码
-```Python
+```python
class Solution:
def divisorGame(self, n: int) -> bool:
return n & 1 == 0
diff --git "a/Solutions/1028. \344\273\216\345\205\210\345\272\217\351\201\215\345\216\206\350\277\230\345\216\237\344\272\214\345\217\211\346\240\221.md" "b/Solutions/1028. \344\273\216\345\205\210\345\272\217\351\201\215\345\216\206\350\277\230\345\216\237\344\272\214\345\217\211\346\240\221.md"
index e797f04b..8c4bb1d8 100644
--- "a/Solutions/1028. \344\273\216\345\205\210\345\272\217\351\201\215\345\216\206\350\277\230\345\216\237\344\272\214\345\217\211\346\240\221.md"
+++ "b/Solutions/1028. \344\273\216\345\205\210\345\272\217\351\201\215\345\216\206\350\277\230\345\216\237\344\272\214\345\217\211\346\240\221.md"
@@ -33,7 +33,7 @@
## 代码
-```Python
+```python
class Solution:
def recoverFromPreorder(self, traversal: str) -> Optional[TreeNode]:
stack = []
diff --git "a/Solutions/1029. \344\270\244\345\234\260\350\260\203\345\272\246.md" "b/Solutions/1029. \344\270\244\345\234\260\350\260\203\345\272\246.md"
index ad0a78c5..bfd47bb5 100644
--- "a/Solutions/1029. \344\270\244\345\234\260\350\260\203\345\272\246.md"
+++ "b/Solutions/1029. \344\270\244\345\234\260\350\260\203\345\272\246.md"
@@ -20,7 +20,7 @@
- 示例 1:
-```Python
+```python
输入:costs = [[10,20],[30,200],[400,50],[30,20]]
输出:110
解释:
@@ -44,7 +44,7 @@
### 思路 1:贪心算法代码
-```Python
+```python
class Solution:
def twoCitySchedCost(self, costs: List[List[int]]) -> int:
costs.sort(key=lambda x:x[1] - x[0])
diff --git "a/Solutions/1034. \350\276\271\347\225\214\347\235\200\350\211\262.md" "b/Solutions/1034. \350\276\271\347\225\214\347\235\200\350\211\262.md"
index 69780f10..201c6cea 100644
--- "a/Solutions/1034. \350\276\271\347\225\214\347\235\200\350\211\262.md"
+++ "b/Solutions/1034. \350\276\271\347\225\214\347\235\200\350\211\262.md"
@@ -20,7 +20,7 @@
## 代码
-```Python
+```python
class Solution:
directs = [(0, 1), (0, -1), (1, 0), (-1, 0)]
diff --git "a/Solutions/1035. \344\270\215\347\233\270\344\272\244\347\232\204\347\272\277.md" "b/Solutions/1035. \344\270\215\347\233\270\344\272\244\347\232\204\347\272\277.md"
index dbf552cd..a1c4496b 100644
--- "a/Solutions/1035. \344\270\215\347\233\270\344\272\244\347\232\204\347\272\277.md"
+++ "b/Solutions/1035. \344\270\215\347\233\270\344\272\244\347\232\204\347\272\277.md"
@@ -31,7 +31,7 @@
## 代码
-```Python
+```python
class Solution:
def maxUncrossedLines(self, nums1: List[int], nums2: List[int]) -> int:
size1 = len(nums1)
diff --git "a/Solutions/1037. \346\234\211\346\225\210\347\232\204\345\233\236\346\227\213\351\225\226.md" "b/Solutions/1037. \346\234\211\346\225\210\347\232\204\345\233\236\346\227\213\351\225\226.md"
index d79ff69d..2e701bfc 100644
--- "a/Solutions/1037. \346\234\211\346\225\210\347\232\204\345\233\236\346\227\213\351\225\226.md"
+++ "b/Solutions/1037. \346\234\211\346\225\210\347\232\204\345\233\236\346\227\213\351\225\226.md"
@@ -20,14 +20,14 @@
- 示例 1:
-```Python
+```python
输入:points = [[1,1],[2,3],[3,2]]
输出:True
```
- 示例 2:
-```Python
+```python
输入:points = [[1,1],[2,2],[3,3]]
输出:False
```
@@ -44,7 +44,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def isBoomerang(self, points: List[List[int]]) -> bool:
x1, y1 = points[0]
diff --git "a/Solutions/1038. \344\273\216\344\272\214\345\217\211\346\220\234\347\264\242\346\240\221\345\210\260\346\233\264\345\244\247\345\222\214\346\240\221.md" "b/Solutions/1038. \344\273\216\344\272\214\345\217\211\346\220\234\347\264\242\346\240\221\345\210\260\346\233\264\345\244\247\345\222\214\346\240\221.md"
index 35b08663..fc981c0f 100644
--- "a/Solutions/1038. \344\273\216\344\272\214\345\217\211\346\220\234\347\264\242\346\240\221\345\210\260\346\233\264\345\244\247\345\222\214\346\240\221.md"
+++ "b/Solutions/1038. \344\273\216\344\272\214\345\217\211\346\220\234\347\264\242\346\240\221\345\210\260\346\233\264\345\244\247\345\222\214\346\240\221.md"
@@ -27,7 +27,7 @@
## 代码
-```Python
+```python
class Solution:
pre = 0
diff --git "a/Solutions/1039. \345\244\232\350\276\271\345\275\242\344\270\211\350\247\222\345\211\226\345\210\206\347\232\204\346\234\200\344\275\216\345\276\227\345\210\206.md" "b/Solutions/1039. \345\244\232\350\276\271\345\275\242\344\270\211\350\247\222\345\211\226\345\210\206\347\232\204\346\234\200\344\275\216\345\276\227\345\210\206.md"
index da693bb8..0d916bd3 100644
--- "a/Solutions/1039. \345\244\232\350\276\271\345\275\242\344\270\211\350\247\222\345\211\226\345\210\206\347\232\204\346\234\200\344\275\216\345\276\227\345\210\206.md"
+++ "b/Solutions/1039. \345\244\232\350\276\271\345\275\242\344\270\211\350\247\222\345\211\226\345\210\206\347\232\204\346\234\200\344\275\216\345\276\227\345\210\206.md"
@@ -23,7 +23,7 @@

-```Python
+```python
输入:values = [1,2,3]
输出:6
解释:多边形已经三角化,唯一三角形的分数为 6。
@@ -33,7 +33,7 @@

-```Python
+```python
输入:values = [3,7,4,5]
输出:144
解释:有两种三角剖分,可能得分分别为:3*7*5 + 4*5*7 = 245,或 3*4*5 + 3*4*7 = 144。最低分数为 144。
@@ -79,7 +79,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def minScoreTriangulation(self, values: List[int]) -> int:
size = len(values)
diff --git "a/Solutions/1047. \345\210\240\351\231\244\345\255\227\347\254\246\344\270\262\344\270\255\347\232\204\346\211\200\346\234\211\347\233\270\351\202\273\351\207\215\345\244\215\351\241\271.md" "b/Solutions/1047. \345\210\240\351\231\244\345\255\227\347\254\246\344\270\262\344\270\255\347\232\204\346\211\200\346\234\211\347\233\270\351\202\273\351\207\215\345\244\215\351\241\271.md"
index a71ca0e8..adce2874 100644
--- "a/Solutions/1047. \345\210\240\351\231\244\345\255\227\347\254\246\344\270\262\344\270\255\347\232\204\346\211\200\346\234\211\347\233\270\351\202\273\351\207\215\345\244\215\351\241\271.md"
+++ "b/Solutions/1047. \345\210\240\351\231\244\345\255\227\347\254\246\344\270\262\344\270\255\347\232\204\346\211\200\346\234\211\347\233\270\351\202\273\351\207\215\345\244\215\351\241\271.md"
@@ -15,7 +15,7 @@
## 代码
-```Python
+```python
class Solution:
def removeDuplicates(self, S: str) -> str:
stack = []
diff --git "a/Solutions/1049. \346\234\200\345\220\216\344\270\200\345\235\227\347\237\263\345\244\264\347\232\204\351\207\215\351\207\217 II.md" "b/Solutions/1049. \346\234\200\345\220\216\344\270\200\345\235\227\347\237\263\345\244\264\347\232\204\351\207\215\351\207\217 II.md"
index 6fe9423e..c49e695d 100644
--- "a/Solutions/1049. \346\234\200\345\220\216\344\270\200\345\235\227\347\237\263\345\244\264\347\232\204\351\207\215\351\207\217 II.md"
+++ "b/Solutions/1049. \346\234\200\345\220\216\344\270\200\345\235\227\347\237\263\345\244\264\347\232\204\351\207\215\351\207\217 II.md"
@@ -21,7 +21,7 @@
- 示例 1:
-```Python
+```python
输入:stones = [2,7,4,1,8,1]
输出:1
解释:
@@ -33,7 +33,7 @@
- 示例 2:
-```Python
+```python
输入:stones = [31,26,33,21,40]
输出:5
```
@@ -75,7 +75,7 @@ $dp[w] = max \lbrace dp[w], dp[w - stones[i - 1]] + stones[i - 1] \rbrace$。
### 思路 1:代码
-```Python
+```python
class Solution:
def lastStoneWeightII(self, stones: List[int]) -> int:
W = 1500
diff --git "a/Solutions/1052. \347\210\261\347\224\237\346\260\224\347\232\204\344\271\246\345\272\227\350\200\201\346\235\277.md" "b/Solutions/1052. \347\210\261\347\224\237\346\260\224\347\232\204\344\271\246\345\272\227\350\200\201\346\235\277.md"
index d68cb249..910ae357 100644
--- "a/Solutions/1052. \347\210\261\347\224\237\346\260\224\347\232\204\344\271\246\345\272\227\350\200\201\346\235\277.md"
+++ "b/Solutions/1052. \347\210\261\347\224\237\346\260\224\347\232\204\344\271\246\345\272\227\350\200\201\346\235\277.md"
@@ -28,7 +28,7 @@
## 代码
-```Python
+```python
class Solution:
def maxSatisfied(self, customers: List[int], grumpy: List[int], minutes: int) -> int:
left = 0
diff --git "a/Solutions/1065. \345\255\227\347\254\246\344\270\262\347\232\204\347\264\242\345\274\225\345\257\271.md" "b/Solutions/1065. \345\255\227\347\254\246\344\270\262\347\232\204\347\264\242\345\274\225\345\257\271.md"
index 11614269..0fcc7238 100644
--- "a/Solutions/1065. \345\255\227\347\254\246\344\270\262\347\232\204\347\264\242\345\274\225\345\257\271.md"
+++ "b/Solutions/1065. \345\255\227\347\254\246\344\270\262\347\232\204\347\264\242\345\274\225\345\257\271.md"
@@ -17,7 +17,7 @@
## 代码
-```Python
+```python
class Trie:
def __init__(self):
diff --git "a/Solutions/1079. \346\264\273\345\255\227\345\215\260\345\210\267.md" "b/Solutions/1079. \346\264\273\345\255\227\345\215\260\345\210\267.md"
index 91cdf6b7..4371f155 100644
--- "a/Solutions/1079. \346\264\273\345\255\227\345\215\260\345\210\267.md"
+++ "b/Solutions/1079. \346\264\273\345\255\227\345\215\260\345\210\267.md"
@@ -17,7 +17,7 @@
## 代码
-```Python
+```python
class Solution:
ans = 0
def backtrack(self, tile_map):
diff --git "a/Solutions/1081. \344\270\215\345\220\214\345\255\227\347\254\246\347\232\204\346\234\200\345\260\217\345\255\220\345\272\217\345\210\227.md" "b/Solutions/1081. \344\270\215\345\220\214\345\255\227\347\254\246\347\232\204\346\234\200\345\260\217\345\255\220\345\272\217\345\210\227.md"
index 536f7614..f24281be 100644
--- "a/Solutions/1081. \344\270\215\345\220\214\345\255\227\347\254\246\347\232\204\346\234\200\345\260\217\345\255\220\345\272\217\345\210\227.md"
+++ "b/Solutions/1081. \344\270\215\345\220\214\345\255\227\347\254\246\347\232\204\346\234\200\345\260\217\345\255\220\345\272\217\345\210\227.md"
@@ -18,14 +18,14 @@
- 示例 1:
-```Python
+```python
输入:s = "bcabc"
输出:"abc"
```
- 示例 2:
-```Python
+```python
输入:s = "cbacdcbc"
输出:"acdb"
```
@@ -55,7 +55,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def removeDuplicateLetters(self, s: str) -> str:
stack = []
diff --git "a/Solutions/1089. \345\244\215\345\206\231\351\233\266.md" "b/Solutions/1089. \345\244\215\345\206\231\351\233\266.md"
index 226444ba..8954cedb 100644
--- "a/Solutions/1089. \345\244\215\345\206\231\351\233\266.md"
+++ "b/Solutions/1089. \345\244\215\345\206\231\351\233\266.md"
@@ -19,7 +19,7 @@
- 示例 1:
-```Python
+```python
输入:arr = [1,0,2,3,0,4,5,0]
输出:[1,0,0,2,3,0,0,4]
解释:调用函数后,输入的数组将被修改为:[1,0,0,2,3,0,0,4]
@@ -27,7 +27,7 @@
- 示例 2:
-```Python
+```python
输入:arr = [1,2,3]
输出:[1,2,3]
解释:调用函数后,输入的数组将被修改为:[1,2,3]
@@ -53,7 +53,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def duplicateZeros(self, arr: List[int]) -> None:
"""
diff --git "a/Solutions/1091. \344\272\214\350\277\233\345\210\266\347\237\251\351\230\265\344\270\255\347\232\204\346\234\200\347\237\255\350\267\257\345\276\204.md" "b/Solutions/1091. \344\272\214\350\277\233\345\210\266\347\237\251\351\230\265\344\270\255\347\232\204\346\234\200\347\237\255\350\267\257\345\276\204.md"
index bcc281c1..6ac4cb8b 100644
--- "a/Solutions/1091. \344\272\214\350\277\233\345\210\266\347\237\251\351\230\265\344\270\255\347\232\204\346\234\200\347\237\255\350\267\257\345\276\204.md"
+++ "b/Solutions/1091. \344\272\214\350\277\233\345\210\266\347\237\251\351\230\265\344\270\255\347\232\204\346\234\200\347\237\255\350\267\257\345\276\204.md"
@@ -26,7 +26,7 @@
## 代码
-```Python
+```python
class Solution:
def shortestPathBinaryMatrix(self, grid: List[List[int]]) -> int:
if grid[0][0] == 1:
diff --git "a/Solutions/1095. \345\261\261\350\204\211\346\225\260\347\273\204\344\270\255\346\237\245\346\211\276\347\233\256\346\240\207\345\200\274.md" "b/Solutions/1095. \345\261\261\350\204\211\346\225\260\347\273\204\344\270\255\346\237\245\346\211\276\347\233\256\346\240\207\345\200\274.md"
index 6d95106d..e9f5cb67 100644
--- "a/Solutions/1095. \345\261\261\350\204\211\346\225\260\347\273\204\344\270\255\346\237\245\346\211\276\347\233\256\346\240\207\345\200\274.md"
+++ "b/Solutions/1095. \345\261\261\350\204\211\346\225\260\347\273\204\344\270\255\346\237\245\346\211\276\347\233\256\346\240\207\345\200\274.md"
@@ -42,7 +42,7 @@
## 代码
-```Python
+```python
#class MountainArray:
# def get(self, index: int) -> int:
# def length(self) -> int:
diff --git "a/Solutions/1099. \345\260\217\344\272\216 K \347\232\204\344\270\244\346\225\260\344\271\213\345\222\214.md" "b/Solutions/1099. \345\260\217\344\272\216 K \347\232\204\344\270\244\346\225\260\344\271\213\345\222\214.md"
index 8b88f296..8067f974 100644
--- "a/Solutions/1099. \345\260\217\344\272\216 K \347\232\204\344\270\244\346\225\260\344\271\213\345\222\214.md"
+++ "b/Solutions/1099. \345\260\217\344\272\216 K \347\232\204\344\270\244\346\225\260\344\271\213\345\222\214.md"
@@ -22,7 +22,7 @@
## 代码
-```Python
+```python
class Solution:
def twoSumLessThanK(self, nums: List[int], k: int) -> int:
diff --git "a/Solutions/1100. \351\225\277\345\272\246\344\270\272 K \347\232\204\346\227\240\351\207\215\345\244\215\345\255\227\347\254\246\345\255\220\344\270\262.md" "b/Solutions/1100. \351\225\277\345\272\246\344\270\272 K \347\232\204\346\227\240\351\207\215\345\244\215\345\255\227\347\254\246\345\255\220\344\270\262.md"
index 0f40cfb8..9848d465 100644
--- "a/Solutions/1100. \351\225\277\345\272\246\344\270\272 K \347\232\204\346\227\240\351\207\215\345\244\215\345\255\227\347\254\246\345\255\220\344\270\262.md"
+++ "b/Solutions/1100. \351\225\277\345\272\246\344\270\272 K \347\232\204\346\227\240\351\207\215\345\244\215\345\255\227\347\254\246\345\255\220\344\270\262.md"
@@ -23,7 +23,7 @@
## 代码
-```Python
+```python
import collections
class Solution:
diff --git "a/Solutions/1103. \345\210\206\347\263\226\346\236\234 II.md" "b/Solutions/1103. \345\210\206\347\263\226\346\236\234 II.md"
index 86c8b7e0..9a0c99d7 100644
--- "a/Solutions/1103. \345\210\206\347\263\226\346\236\234 II.md"
+++ "b/Solutions/1103. \345\210\206\347\263\226\346\236\234 II.md"
@@ -26,7 +26,7 @@
- 示例 1:
-```Python
+```python
输入:candies = 7, num_people = 4
输出:[1,2,3,1]
解释:
@@ -38,7 +38,7 @@
- 示例 2:
-```Python
+```python
输入:candies = 10, num_people = 3
输出:[5,2,3]
解释:
@@ -56,7 +56,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def distributeCandies(self, candies: int, num_people: int) -> List[int]:
ans = [0 for _ in range(num_people)]
diff --git "a/Solutions/1108. IP \345\234\260\345\235\200\346\227\240\346\225\210\345\214\226.md" "b/Solutions/1108. IP \345\234\260\345\235\200\346\227\240\346\225\210\345\214\226.md"
index c1b8ed8f..e3d87ac8 100644
--- "a/Solutions/1108. IP \345\234\260\345\235\200\346\227\240\346\225\210\345\214\226.md"
+++ "b/Solutions/1108. IP \345\234\260\345\235\200\346\227\240\346\225\210\345\214\226.md"
@@ -17,7 +17,7 @@
- 示例 1:
-```Python
+```python
输入:address = "255.100.50.0"
输出:"255[.]100[.]50[.]0"
```
@@ -30,7 +30,7 @@
### 思路 1:字符串替换代码
-```Python
+```python
class Solution:
def defangIPaddr(self, address: str) -> str:
return address.replace('.', '[.]')
diff --git "a/Solutions/1109. \350\210\252\347\217\255\351\242\204\350\256\242\347\273\237\350\256\241.md" "b/Solutions/1109. \350\210\252\347\217\255\351\242\204\350\256\242\347\273\237\350\256\241.md"
index ce82b7af..ae9b2688 100644
--- "a/Solutions/1109. \350\210\252\347\217\255\351\242\204\350\256\242\347\273\237\350\256\241.md"
+++ "b/Solutions/1109. \350\210\252\347\217\255\351\242\204\350\256\242\347\273\237\350\256\241.md"
@@ -21,7 +21,7 @@
- 示例 1:
-```Python
+```python
给定 n = 5。初始 answer = [0, 0, 0, 0, 0]
航班编号 1 2 3 4 5
@@ -46,7 +46,7 @@
### 思路 1 线段树代码:
-```Python
+```python
# 线段树的节点类
class SegTreeNode:
def __init__(self, val=0):
diff --git "a/Solutions/1122. \346\225\260\347\273\204\347\232\204\347\233\270\345\257\271\346\216\222\345\272\217.md" "b/Solutions/1122. \346\225\260\347\273\204\347\232\204\347\233\270\345\257\271\346\216\222\345\272\217.md"
index 12fed2c4..1ac5c788 100644
--- "a/Solutions/1122. \346\225\260\347\273\204\347\232\204\347\233\270\345\257\271\346\216\222\345\272\217.md"
+++ "b/Solutions/1122. \346\225\260\347\273\204\347\232\204\347\233\270\345\257\271\346\216\222\345\272\217.md"
@@ -18,14 +18,14 @@
- 示例 1:
-```Python
+```python
输入:arr1 = [2,3,1,3,2,4,6,7,9,2,19], arr2 = [2,1,4,3,9,6]
输出:[2,2,2,1,4,3,3,9,6,7,19]
```
- 示例 2:
-```Python
+```python
输入:arr1 = [28,6,22,8,44,17], arr2 = [22,28,8,6]
输出:[22,28,8,6,17,44]
```
@@ -43,7 +43,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def relativeSortArray(self, arr1: List[int], arr2: List[int]) -> List[int]:
# 计算待排序序列中最大值元素 arr_max 和最小值元素 arr_min
diff --git "a/Solutions/1136. \345\271\266\350\241\214\350\257\276\347\250\213.md" "b/Solutions/1136. \345\271\266\350\241\214\350\257\276\347\250\213.md"
index 1d2ae435..2412ca76 100644
--- "a/Solutions/1136. \345\271\266\350\241\214\350\257\276\347\250\213.md"
+++ "b/Solutions/1136. \345\271\266\350\241\214\350\257\276\347\250\213.md"
@@ -23,7 +23,7 @@
## 代码
-```Python
+```python
import collections
class Solution:
diff --git "a/Solutions/1137. \347\254\254 N \344\270\252\346\263\260\346\263\242\351\202\243\345\245\221\346\225\260.md" "b/Solutions/1137. \347\254\254 N \344\270\252\346\263\260\346\263\242\351\202\243\345\245\221\346\225\260.md"
index 0efc8947..23963918 100644
--- "a/Solutions/1137. \347\254\254 N \344\270\252\346\263\260\346\263\242\351\202\243\345\245\221\346\225\260.md"
+++ "b/Solutions/1137. \347\254\254 N \344\270\252\346\263\260\346\263\242\351\202\243\345\245\221\346\225\260.md"
@@ -19,7 +19,7 @@
- 示例 1:
-```Python
+```python
输入:n = 4
输出:4
解释:
@@ -29,7 +29,7 @@ T_4 = 1 + 1 + 2 = 4
- 示例 2:
-```Python
+```python
输入:n = 25
输出:1389537
```
@@ -48,7 +48,7 @@ T_4 = 1 + 1 + 2 = 4
### 思路 1:代码
-```Python
+```python
class Solution:
def tribonacci(self, n: int) -> int:
# 使用数组保存已经求解过的 T(k) 的结果
@@ -96,7 +96,7 @@ class Solution:
### 思路 2:代码
-```Python
+```python
class Solution:
def tribonacci(self, n: int) -> int:
if n == 0:
diff --git "a/Solutions/1143. \346\234\200\351\225\277\345\205\254\345\205\261\345\255\220\345\272\217\345\210\227.md" "b/Solutions/1143. \346\234\200\351\225\277\345\205\254\345\205\261\345\255\220\345\272\217\345\210\227.md"
index f13b1fcb..b7ccac26 100644
--- "a/Solutions/1143. \346\234\200\351\225\277\345\205\254\345\205\261\345\255\220\345\272\217\345\210\227.md"
+++ "b/Solutions/1143. \346\234\200\351\225\277\345\205\254\345\205\261\345\255\220\345\272\217\345\210\227.md"
@@ -20,7 +20,7 @@
- 示例 1:
-```Python
+```python
输入:text1 = "abcde", text2 = "ace"
输出:3
解释:最长公共子序列是 "ace",它的长度为 3。
@@ -28,7 +28,7 @@
- 示例 2:
-```Python
+```python
输入:text1 = "abc", text2 = "abc"
输出:3
解释:最长公共子序列是 "abc",它的长度为 3。
@@ -66,7 +66,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def longestCommonSubsequence(self, text1: str, text2: str) -> int:
size1 = len(text1)
diff --git "a/Solutions/1151. \346\234\200\345\260\221\344\272\244\346\215\242\346\254\241\346\225\260\346\235\245\347\273\204\345\220\210\346\211\200\346\234\211\347\232\204 1.md" "b/Solutions/1151. \346\234\200\345\260\221\344\272\244\346\215\242\346\254\241\346\225\260\346\235\245\347\273\204\345\220\210\346\211\200\346\234\211\347\232\204 1.md"
index fcb388da..db5cb4a7 100644
--- "a/Solutions/1151. \346\234\200\345\260\221\344\272\244\346\215\242\346\254\241\346\225\260\346\235\245\347\273\204\345\220\210\346\211\200\346\234\211\347\232\204 1.md"
+++ "b/Solutions/1151. \346\234\200\345\260\221\344\272\244\346\215\242\346\254\241\346\225\260\346\235\245\347\273\204\345\220\210\346\211\200\346\234\211\347\232\204 1.md"
@@ -25,7 +25,7 @@
## 代码
-```Python
+```python
class Solution:
def minSwaps(self, data: List[int]) -> int:
window_size = 0
diff --git "a/Solutions/1155. \346\216\267\351\252\260\345\255\220\347\255\211\344\272\216\347\233\256\346\240\207\345\222\214\347\232\204\346\226\271\346\263\225\346\225\260.md" "b/Solutions/1155. \346\216\267\351\252\260\345\255\220\347\255\211\344\272\216\347\233\256\346\240\207\345\222\214\347\232\204\346\226\271\346\263\225\346\225\260.md"
index db3d98a2..fb02bdbc 100644
--- "a/Solutions/1155. \346\216\267\351\252\260\345\255\220\347\255\211\344\272\216\347\233\256\346\240\207\345\222\214\347\232\204\346\226\271\346\263\225\346\225\260.md"
+++ "b/Solutions/1155. \346\216\267\351\252\260\345\255\220\347\255\211\344\272\216\347\233\256\346\240\207\345\222\214\347\232\204\346\226\271\346\263\225\346\225\260.md"
@@ -18,7 +18,7 @@
- 示例 1:
-```Python
+```python
输入:n = 1, k = 6, target = 3
输出:1
解释:你扔一个有 6 个面的骰子。
@@ -27,7 +27,7 @@
- 示例 2:
-```Python
+```python
输入:n = 2, k = 6, target = 7
输出:6
解释:你扔两个骰子,每个骰子有 6 个面。
@@ -62,7 +62,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def numRollsToTarget(self, n: int, k: int, target: int) -> int:
dp = [0 for _ in range(target + 1)]
diff --git "a/Solutions/1161. \346\234\200\345\244\247\345\261\202\345\206\205\345\205\203\347\264\240\345\222\214.md" "b/Solutions/1161. \346\234\200\345\244\247\345\261\202\345\206\205\345\205\203\347\264\240\345\222\214.md"
index 582d8648..ddfd2d9e 100644
--- "a/Solutions/1161. \346\234\200\345\244\247\345\261\202\345\206\205\345\205\203\347\264\240\345\222\214.md"
+++ "b/Solutions/1161. \346\234\200\345\244\247\345\261\202\345\206\205\345\205\203\347\264\240\345\222\214.md"
@@ -20,7 +20,7 @@

-```Python
+```python
输入:root = [1,7,0,7,-8,null,null]
输出:2
解释:
@@ -32,7 +32,7 @@
- 示例 2:
-```Python
+```python
输入:root = [989,null,10250,98693,-89388,null,null,null,-32127]
输出:2
```
@@ -47,7 +47,7 @@
### 思路 1:代码
-```Python
+```python
# Definition for a binary tree node.
# class TreeNode:
# def __init__(self, val=0, left=None, right=None):
diff --git "a/Solutions/1176. \345\201\245\350\272\253\350\256\241\345\210\222\350\257\204\344\274\260.md" "b/Solutions/1176. \345\201\245\350\272\253\350\256\241\345\210\222\350\257\204\344\274\260.md"
index 9799aa6a..9e00ed50 100644
--- "a/Solutions/1176. \345\201\245\350\272\253\350\256\241\345\210\222\350\257\204\344\274\260.md"
+++ "b/Solutions/1176. \345\201\245\350\272\253\350\256\241\345\210\222\350\257\204\344\274\260.md"
@@ -30,7 +30,7 @@
## 代码
-```Python
+```python
class Solution:
def dietPlanPerformance(self, calories: List[int], k: int, lower: int, upper: int) -> int:
left, right = 0, 0
diff --git "a/Solutions/1184. \345\205\254\344\272\244\347\253\231\351\227\264\347\232\204\350\267\235\347\246\273.md" "b/Solutions/1184. \345\205\254\344\272\244\347\253\231\351\227\264\347\232\204\350\267\235\347\246\273.md"
index da055384..a7a1b4bd 100644
--- "a/Solutions/1184. \345\205\254\344\272\244\347\253\231\351\227\264\347\232\204\350\267\235\347\246\273.md"
+++ "b/Solutions/1184. \345\205\254\344\272\244\347\253\231\351\227\264\347\232\204\350\267\235\347\246\273.md"
@@ -22,7 +22,7 @@

-```Python
+```python
输入:distance = [1,2,3,4], start = 0, destination = 1
输出:1
解释:公交站 0 和 1 之间的距离是 1 或 9,最小值是 1。
@@ -32,7 +32,7 @@

-```Python
+```python
输入:distance = [1,2,3,4], start = 0, destination = 2
输出:3
解释:公交站 0 和 2 之间的距离是 3 或 7,最小值是 3。
@@ -49,7 +49,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def distanceBetweenBusStops(self, distance: List[int], start: int, destination: int) -> int:
start, destination = min(start, destination), max(start, destination)
diff --git "a/Solutions/1202. \344\272\244\346\215\242\345\255\227\347\254\246\344\270\262\344\270\255\347\232\204\345\205\203\347\264\240.md" "b/Solutions/1202. \344\272\244\346\215\242\345\255\227\347\254\246\344\270\262\344\270\255\347\232\204\345\205\203\347\264\240.md"
index 1063d26a..48683d57 100644
--- "a/Solutions/1202. \344\272\244\346\215\242\345\255\227\347\254\246\344\270\262\344\270\255\347\232\204\345\205\203\347\264\240.md"
+++ "b/Solutions/1202. \344\272\244\346\215\242\345\255\227\347\254\246\344\270\262\344\270\255\347\232\204\345\205\203\347\264\240.md"
@@ -20,7 +20,7 @@
- 示例 1:
-```Python
+```python
输入:s = "dcab", pairs = [[0,3],[1,2]]
输出:"bacd"
解释:
@@ -30,7 +30,7 @@
- 示例 2:
-```Python
+```python
输入:s = "dcab", pairs = [[0,3],[1,2],[0,2]]
输出:"abcd"
解释:
@@ -47,7 +47,7 @@
### 思路 1:代码
-```Python
+```python
import collections
class UnionFind:
diff --git "a/Solutions/1208. \345\260\275\345\217\257\350\203\275\344\275\277\345\255\227\347\254\246\344\270\262\347\233\270\347\255\211.md" "b/Solutions/1208. \345\260\275\345\217\257\350\203\275\344\275\277\345\255\227\347\254\246\344\270\262\347\233\270\347\255\211.md"
index 6a4d7848..4af7af24 100644
--- "a/Solutions/1208. \345\260\275\345\217\257\350\203\275\344\275\277\345\255\227\347\254\246\344\270\262\347\233\270\347\255\211.md"
+++ "b/Solutions/1208. \345\260\275\345\217\257\350\203\275\344\275\277\345\255\227\347\254\246\344\270\262\347\233\270\347\255\211.md"
@@ -24,7 +24,7 @@
## 代码
-```Python
+```python
class Solution:
def equalSubstring(self, s: str, t: str, maxCost: int) -> int:
size = len(s)
diff --git "a/Solutions/1217. \347\216\251\347\255\271\347\240\201.md" "b/Solutions/1217. \347\216\251\347\255\271\347\240\201.md"
index 5acf0ff2..d75ab4ef 100644
--- "a/Solutions/1217. \347\216\251\347\255\271\347\240\201.md"
+++ "b/Solutions/1217. \347\216\251\347\255\271\347\240\201.md"
@@ -23,7 +23,7 @@
- 示例 1:
-```Python
+```python
输入:position = [2,2,2,3,3]
输出:2
解释:我们可以把位置3的两个芯片移到位置 2。每一步的成本为 1。总成本 = 2。
@@ -48,7 +48,7 @@
### 思路 1:贪心算法代码
-```Python
+```python
class Solution:
def minCostToMoveChips(self, position: List[int]) -> int:
odd, even = 0, 0
diff --git "a/Solutions/1220. \347\273\237\350\256\241\345\205\203\351\237\263\345\255\227\346\257\215\345\272\217\345\210\227\347\232\204\346\225\260\347\233\256.md" "b/Solutions/1220. \347\273\237\350\256\241\345\205\203\351\237\263\345\255\227\346\257\215\345\272\217\345\210\227\347\232\204\346\225\260\347\233\256.md"
index acb8cb2c..169f00f7 100644
--- "a/Solutions/1220. \347\273\237\350\256\241\345\205\203\351\237\263\345\255\227\346\257\215\345\272\217\345\210\227\347\232\204\346\225\260\347\233\256.md"
+++ "b/Solutions/1220. \347\273\237\350\256\241\345\205\203\351\237\263\345\255\227\346\257\215\345\272\217\345\210\227\347\232\204\346\225\260\347\233\256.md"
@@ -24,7 +24,7 @@
- 示例 1:
-```Python
+```python
输入:n = 2
输出:10
解释:所有可能的字符串分别是:"ae", "ea", "ei", "ia", "ie", "io", "iu", "oi", "ou" 和 "ua"。
@@ -69,7 +69,7 @@ $\begin{cases} dp[i][0] = dp[i - 1][1] + dp[i - 1][2] + dp[i - 1][4] \cr dp[i][1
### 思路 1:动态规划代码
-```Python
+```python
class Solution:
def countVowelPermutation(self, n: int) -> int:
mod = 10 ** 9 + 7
diff --git "a/Solutions/1227. \351\243\236\346\234\272\345\272\247\344\275\215\345\210\206\351\205\215\346\246\202\347\216\207.md" "b/Solutions/1227. \351\243\236\346\234\272\345\272\247\344\275\215\345\210\206\351\205\215\346\246\202\347\216\207.md"
index b31eb1f7..e0f29531 100644
--- "a/Solutions/1227. \351\243\236\346\234\272\345\272\247\344\275\215\345\210\206\351\205\215\346\246\202\347\216\207.md"
+++ "b/Solutions/1227. \351\243\236\346\234\272\345\272\247\344\275\215\345\210\206\351\205\215\346\246\202\347\216\207.md"
@@ -20,7 +20,7 @@
- 示例 1:
-```Python
+```python
输入:n = 1
输出:1.00000
解释:第一个人只会坐在自己的位置上。
@@ -28,7 +28,7 @@
- 示例 2:
-```Python
+```python
输入: n = 2
输出: 0.50000
解释:在第一个人选好座位坐下后,第二个人坐在自己的座位上的概率是 0.5。
@@ -97,7 +97,7 @@ $f(n) = \begin{cases} 1.0 & n = 1 \cr 0.5 & n \ge 2 \end{cases}$
### 思路 1:代码
-```Python
+```python
class Solution:
def nthPersonGetsNthSeat(self, n: int) -> float:
if n == 1:
diff --git "a/Solutions/1229. \345\256\211\346\216\222\344\274\232\350\256\256\346\227\245\347\250\213.md" "b/Solutions/1229. \345\256\211\346\216\222\344\274\232\350\256\256\346\227\245\347\250\213.md"
index 8648b111..51210c99 100644
--- "a/Solutions/1229. \345\256\211\346\216\222\344\274\232\350\256\256\346\227\245\347\250\213.md"
+++ "b/Solutions/1229. \345\256\211\346\216\222\344\274\232\350\256\256\346\227\245\347\250\213.md"
@@ -28,7 +28,7 @@
## 代码
-```Python
+```python
class Solution:
def minAvailableDuration(self, slots1: List[List[int]], slots2: List[List[int]], duration: int) -> List[int]:
slots1.sort()
diff --git "a/Solutions/1232. \347\274\200\347\202\271\346\210\220\347\272\277.md" "b/Solutions/1232. \347\274\200\347\202\271\346\210\220\347\272\277.md"
index 35e2488d..f853fda5 100644
--- "a/Solutions/1232. \347\274\200\347\202\271\346\210\220\347\272\277.md"
+++ "b/Solutions/1232. \347\274\200\347\202\271\346\210\220\347\272\277.md"
@@ -30,7 +30,7 @@
## 代码
-```Python
+```python
class Solution:
def checkStraightLine(self, coordinates: List[List[int]]) -> bool:
x1 = coordinates[1][0] - coordinates[0][0]
diff --git "a/Solutions/1245. \346\240\221\347\232\204\347\233\264\345\276\204.md" "b/Solutions/1245. \346\240\221\347\232\204\347\233\264\345\276\204.md"
index 6dbc1917..848324db 100644
--- "a/Solutions/1245. \346\240\221\347\232\204\347\233\264\345\276\204.md"
+++ "b/Solutions/1245. \346\240\221\347\232\204\347\233\264\345\276\204.md"
@@ -22,7 +22,7 @@

-```Python
+```python
输入:edges = [[0,1],[0,2]]
输出:2
解释:
@@ -33,7 +33,7 @@

-```Python
+```python
输入:edges = [[0,1],[1,2],[2,3],[1,4],[4,5]]
输出:4
解释:
@@ -61,7 +61,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def __init__(self):
self.ans = 0
diff --git "a/Solutions/1247. \344\272\244\346\215\242\345\255\227\347\254\246\344\275\277\345\276\227\345\255\227\347\254\246\344\270\262\347\233\270\345\220\214.md" "b/Solutions/1247. \344\272\244\346\215\242\345\255\227\347\254\246\344\275\277\345\276\227\345\255\227\347\254\246\344\270\262\347\233\270\345\220\214.md"
index 22a55466..42b0256c 100644
--- "a/Solutions/1247. \344\272\244\346\215\242\345\255\227\347\254\246\344\275\277\345\276\227\345\255\227\347\254\246\344\270\262\347\233\270\345\220\214.md"
+++ "b/Solutions/1247. \344\272\244\346\215\242\345\255\227\347\254\246\344\275\277\345\276\227\345\255\227\347\254\246\344\270\262\347\233\270\345\220\214.md"
@@ -21,7 +21,7 @@
- 示例 1:
-```Python
+```python
输入:s1 = "xy", s2 = "yx"
输出:2
解释:
@@ -61,7 +61,7 @@
### 思路 1:贪心算法代码
-```Python
+```python
class Solution:
def minimumSwap(self, s1: str, s2: str) -> int:
xyCnt, yxCnt = 0, 0
diff --git "a/Solutions/1254. \347\273\237\350\256\241\345\260\201\351\227\255\345\262\233\345\261\277\347\232\204\346\225\260\347\233\256.md" "b/Solutions/1254. \347\273\237\350\256\241\345\260\201\351\227\255\345\262\233\345\261\277\347\232\204\346\225\260\347\233\256.md"
index dc7aedf8..a23bab48 100644
--- "a/Solutions/1254. \347\273\237\350\256\241\345\260\201\351\227\255\345\262\233\345\261\277\347\232\204\346\225\260\347\233\256.md"
+++ "b/Solutions/1254. \347\273\237\350\256\241\345\260\201\351\227\255\345\262\233\345\261\277\347\232\204\346\225\260\347\233\256.md"
@@ -24,7 +24,7 @@

-```Python
+```python
输入:grid = [[1,1,1,1,1,1,1,0],[1,0,0,0,0,1,1,0],[1,0,1,0,1,1,1,0],[1,0,0,0,0,1,0,1],[1,1,1,1,1,1,1,0]]
输出:2
解释:灰色区域的岛屿是封闭岛屿,因为这座岛屿完全被水域包围(即被 1 区域包围)。
@@ -34,7 +34,7 @@

-```Python
+```python
输入:grid = [[0,0,1,0,0],[0,1,0,1,0],[0,1,1,1,0]]
输出:1
```
@@ -51,7 +51,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
directs = [(0, 1), (0, -1), (1, 0), (-1, 0)]
diff --git "a/Solutions/1266. \350\256\277\351\227\256\346\211\200\346\234\211\347\202\271\347\232\204\346\234\200\345\260\217\346\227\266\351\227\264.md" "b/Solutions/1266. \350\256\277\351\227\256\346\211\200\346\234\211\347\202\271\347\232\204\346\234\200\345\260\217\346\227\266\351\227\264.md"
index 57c9ce38..1fe14afe 100644
--- "a/Solutions/1266. \350\256\277\351\227\256\346\211\200\346\234\211\347\202\271\347\232\204\346\234\200\345\260\217\346\227\266\351\227\264.md"
+++ "b/Solutions/1266. \350\256\277\351\227\256\346\211\200\346\234\211\347\202\271\347\232\204\346\234\200\345\260\217\346\227\266\351\227\264.md"
@@ -29,7 +29,7 @@

-```Python
+```python
输入:points = [[1,1],[3,4],[-1,0]]
输出:7
解释:一条最佳的访问路径是: [1,1] -> [2,2] -> [3,3] -> [3,4] -> [2,3] -> [1,2] -> [0,1] -> [-1,0]
@@ -38,7 +38,7 @@
一共需要 7 秒
```
-```Python
+```python
输入:points = [[3,2],[-2,2]]
输出:5
```
@@ -67,7 +67,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def minTimeToVisitAllPoints(self, points: List[List[int]]) -> int:
ans = 0
diff --git "a/Solutions/1268. \346\220\234\347\264\242\346\216\250\350\215\220\347\263\273\347\273\237.md" "b/Solutions/1268. \346\220\234\347\264\242\346\216\250\350\215\220\347\263\273\347\273\237.md"
index 641c84de..181f3d8c 100644
--- "a/Solutions/1268. \346\220\234\347\264\242\346\216\250\350\215\220\347\263\273\347\273\237.md"
+++ "b/Solutions/1268. \346\220\234\347\264\242\346\216\250\350\215\220\347\263\273\347\273\237.md"
@@ -23,7 +23,7 @@
## 代码
-```Python
+```python
class Trie:
def __init__(self):
diff --git "a/Solutions/1281. \346\225\264\346\225\260\347\232\204\345\220\204\344\275\215\347\247\257\345\222\214\344\271\213\345\267\256.md" "b/Solutions/1281. \346\225\264\346\225\260\347\232\204\345\220\204\344\275\215\347\247\257\345\222\214\344\271\213\345\267\256.md"
index e707211c..6549c35b 100644
--- "a/Solutions/1281. \346\225\264\346\225\260\347\232\204\345\220\204\344\275\215\347\247\257\345\222\214\344\271\213\345\267\256.md"
+++ "b/Solutions/1281. \346\225\264\346\225\260\347\232\204\345\220\204\344\275\215\347\247\257\345\222\214\344\271\213\345\267\256.md"
@@ -17,7 +17,7 @@
- 示例 1:
-```Python
+```python
输入:n = 234
输出:15
@@ -37,7 +37,7 @@
### 思路 1:数学代码
-```Python
+```python
class Solution:
def subtractProductAndSum(self, n: int) -> int:
product = 1
diff --git "a/Solutions/1296. \345\210\222\345\210\206\346\225\260\347\273\204\344\270\272\350\277\236\347\273\255\346\225\260\345\255\227\347\232\204\351\233\206\345\220\210.md" "b/Solutions/1296. \345\210\222\345\210\206\346\225\260\347\273\204\344\270\272\350\277\236\347\273\255\346\225\260\345\255\227\347\232\204\351\233\206\345\220\210.md"
index c6cd1848..60078b1a 100644
--- "a/Solutions/1296. \345\210\222\345\210\206\346\225\260\347\273\204\344\270\272\350\277\236\347\273\255\346\225\260\345\255\227\347\232\204\351\233\206\345\220\210.md"
+++ "b/Solutions/1296. \345\210\222\345\210\206\346\225\260\347\273\204\344\270\272\350\277\236\347\273\255\346\225\260\345\255\227\347\232\204\351\233\206\345\220\210.md"
@@ -18,7 +18,7 @@
- 示例 1:
-```Python
+```python
输入:nums = [1,2,3,3,4,4,5,6], k = 4
输出:True
解释:数组可以分成 [1,2,3,4] 和 [3,4,5,6]。
@@ -35,7 +35,7 @@
### 思路 1:哈希表 + 排序代码
-```Python
+```python
class Solution:
def isPossibleDivide(self, nums: List[int], k: int) -> bool:
hand_map = collections.defaultdict(int)
diff --git "a/Solutions/1300. \350\275\254\345\217\230\346\225\260\347\273\204\345\220\216\346\234\200\346\216\245\350\277\221\347\233\256\346\240\207\345\200\274\347\232\204\346\225\260\347\273\204\345\222\214.md" "b/Solutions/1300. \350\275\254\345\217\230\346\225\260\347\273\204\345\220\216\346\234\200\346\216\245\350\277\221\347\233\256\346\240\207\345\200\274\347\232\204\346\225\260\347\273\204\345\222\214.md"
index 49a579f3..93b1dbf9 100644
--- "a/Solutions/1300. \350\275\254\345\217\230\346\225\260\347\273\204\345\220\216\346\234\200\346\216\245\350\277\221\347\233\256\346\240\207\345\200\274\347\232\204\346\225\260\347\273\204\345\222\214.md"
+++ "b/Solutions/1300. \350\275\254\345\217\230\346\225\260\347\273\204\345\220\216\346\234\200\346\216\245\350\277\221\347\233\256\346\240\207\345\200\274\347\232\204\346\225\260\347\273\204\345\222\214.md"
@@ -34,7 +34,7 @@
## 代码
-```Python
+```python
class Solution:
# 计算 value 对应的转变后的数组
def calc_sum(self, arr, value, pre_sum):
diff --git "a/Solutions/1305. \344\270\244\346\243\265\344\272\214\345\217\211\346\220\234\347\264\242\346\240\221\344\270\255\347\232\204\346\211\200\346\234\211\345\205\203\347\264\240.md" "b/Solutions/1305. \344\270\244\346\243\265\344\272\214\345\217\211\346\220\234\347\264\242\346\240\221\344\270\255\347\232\204\346\211\200\346\234\211\345\205\203\347\264\240.md"
index 04d283e1..50dfdd16 100644
--- "a/Solutions/1305. \344\270\244\346\243\265\344\272\214\345\217\211\346\220\234\347\264\242\346\240\221\344\270\255\347\232\204\346\211\200\346\234\211\345\205\203\347\264\240.md"
+++ "b/Solutions/1305. \344\270\244\346\243\265\344\272\214\345\217\211\346\220\234\347\264\242\346\240\221\344\270\255\347\232\204\346\211\200\346\234\211\345\205\203\347\264\240.md"
@@ -20,7 +20,7 @@

-```Python
+```python
输入:root1 = [2,1,4], root2 = [1,0,3]
输出:[0,1,1,2,3,4]
```
@@ -29,7 +29,7 @@

-```Python
+```python
输入:root1 = [1,null,8], root2 = [8,1]
输出:[1,1,8,8]
```
@@ -53,7 +53,7 @@
### 思路 1:代码
-```Python
+```python
# Definition for a binary tree node.
# class TreeNode:
# def __init__(self, val=0, left=None, right=None):
diff --git "a/Solutions/1310. \345\255\220\346\225\260\347\273\204\345\274\202\346\210\226\346\237\245\350\257\242.md" "b/Solutions/1310. \345\255\220\346\225\260\347\273\204\345\274\202\346\210\226\346\237\245\350\257\242.md"
index ff0b4e92..d05586f2 100644
--- "a/Solutions/1310. \345\255\220\346\225\260\347\273\204\345\274\202\346\210\226\346\237\245\350\257\242.md"
+++ "b/Solutions/1310. \345\255\220\346\225\260\347\273\204\345\274\202\346\210\226\346\237\245\350\257\242.md"
@@ -21,7 +21,7 @@
- 示例 1:
-```Python
+```python
输入:arr = [1,3,4,8], queries = [[0,1],[1,2],[0,3],[3,3]]
输出:[2,7,14,8]
解释
@@ -52,7 +52,7 @@
### 思路 1:线段树代码
-```Python
+```python
# 线段树的节点类
class SegTreeNode:
def __init__(self, val=0):
diff --git "a/Solutions/1317. \345\260\206\346\225\264\346\225\260\350\275\254\346\215\242\344\270\272\344\270\244\344\270\252\346\227\240\351\233\266\346\225\264\346\225\260\347\232\204\345\222\214.md" "b/Solutions/1317. \345\260\206\346\225\264\346\225\260\350\275\254\346\215\242\344\270\272\344\270\244\344\270\252\346\227\240\351\233\266\346\225\264\346\225\260\347\232\204\345\222\214.md"
index a04627d6..67db29e2 100644
--- "a/Solutions/1317. \345\260\206\346\225\264\346\225\260\350\275\254\346\215\242\344\270\272\344\270\244\344\270\252\346\227\240\351\233\266\346\225\264\346\225\260\347\232\204\345\222\214.md"
+++ "b/Solutions/1317. \345\260\206\346\225\264\346\225\260\350\275\254\346\215\242\344\270\272\344\270\244\344\270\252\346\227\240\351\233\266\346\225\264\346\225\260\347\232\204\345\222\214.md"
@@ -23,7 +23,7 @@
- 示例 1:
-```Python
+```python
输入:n = 2
输出:[1,1]
解释:A = 1, B = 1. A + B = n 并且 A 和 B 的十进制表示形式都不包含任何 0。
@@ -31,7 +31,7 @@
- 示例 2:
-```Python
+```python
输入:n = 11
输出:[2,9]
```
@@ -45,7 +45,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def getNoZeroIntegers(self, n: int) -> List[int]:
for A in range(1, n):
diff --git "a/Solutions/1319. \350\277\236\351\200\232\347\275\221\347\273\234\347\232\204\346\223\215\344\275\234\346\254\241\346\225\260.md" "b/Solutions/1319. \350\277\236\351\200\232\347\275\221\347\273\234\347\232\204\346\223\215\344\275\234\346\254\241\346\225\260.md"
index 61de64d5..6ab07b66 100644
--- "a/Solutions/1319. \350\277\236\351\200\232\347\275\221\347\273\234\347\232\204\346\223\215\344\275\234\346\254\241\346\225\260.md"
+++ "b/Solutions/1319. \350\277\236\351\200\232\347\275\221\347\273\234\347\232\204\346\223\215\344\275\234\346\254\241\346\225\260.md"
@@ -24,7 +24,7 @@
## 代码
-```Python
+```python
class UnionFind:
def __init__(self, n):
diff --git "a/Solutions/1343. \345\244\247\345\260\217\344\270\272 K \344\270\224\345\271\263\345\235\207\345\200\274\345\244\247\344\272\216\347\255\211\344\272\216\351\230\210\345\200\274\347\232\204\345\255\220\346\225\260\347\273\204\346\225\260\347\233\256.md" "b/Solutions/1343. \345\244\247\345\260\217\344\270\272 K \344\270\224\345\271\263\345\235\207\345\200\274\345\244\247\344\272\216\347\255\211\344\272\216\351\230\210\345\200\274\347\232\204\345\255\220\346\225\260\347\273\204\346\225\260\347\233\256.md"
index d9e63d63..cf71ca11 100644
--- "a/Solutions/1343. \345\244\247\345\260\217\344\270\272 K \344\270\224\345\271\263\345\235\207\345\200\274\345\244\247\344\272\216\347\255\211\344\272\216\351\230\210\345\200\274\347\232\204\345\255\220\346\225\260\347\273\204\346\225\260\347\233\256.md"
+++ "b/Solutions/1343. \345\244\247\345\260\217\344\270\272 K \344\270\224\345\271\263\345\235\207\345\200\274\345\244\247\344\272\216\347\255\211\344\272\216\351\230\210\345\200\274\347\232\204\345\255\220\346\225\260\347\273\204\346\225\260\347\233\256.md"
@@ -20,7 +20,7 @@
- 示例 1:
-```Python
+```python
输入:arr = [2,2,2,2,5,5,5,8], k = 3, threshold = 4
输出:3
解释:子数组 [2,5,5],[5,5,5] 和 [5,5,8] 的平均值分别为 4,5 和 6 。其他长度为 3 的子数组的平均值都小于 4 (threshold 的值)。
@@ -28,7 +28,7 @@
- 示例 2:
-```Python
+```python
输入:arr = [11,13,17,23,29,31,7,5,2,3], k = 3, threshold = 5
输出:6
解释:前 6 个长度为 3 的子数组平均值都大于 5 。注意平均值不是整数。
@@ -51,7 +51,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def numOfSubarrays(self, arr: List[int], k: int, threshold: int) -> int:
left = 0
diff --git "a/Solutions/1349. \345\217\202\345\212\240\350\200\203\350\257\225\347\232\204\346\234\200\345\244\247\345\255\246\347\224\237\346\225\260.md" "b/Solutions/1349. \345\217\202\345\212\240\350\200\203\350\257\225\347\232\204\346\234\200\345\244\247\345\255\246\347\224\237\346\225\260.md"
index 5097f2e3..5e878be4 100644
--- "a/Solutions/1349. \345\217\202\345\212\240\350\200\203\350\257\225\347\232\204\346\234\200\345\244\247\345\255\246\347\224\237\346\225\260.md"
+++ "b/Solutions/1349. \345\217\202\345\212\240\350\200\203\350\257\225\347\232\204\346\234\200\345\244\247\345\255\246\347\224\237\346\225\260.md"
@@ -26,7 +26,7 @@

-```Python
+```python
输入:seats = [["#",".","#","#",".","#"],
[".","#","#","#","#","."],
["#",".","#","#",".","#"]]
@@ -36,7 +36,7 @@
- 示例 2:
-```Python
+```python
输入:seats = [[".","#"],
["#","#"],
["#","."],
@@ -86,7 +86,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def maxStudents(self, seats: List[List[str]]) -> int:
rows, cols = len(seats), len(seats[0])
diff --git "a/Solutions/1358. \345\214\205\345\220\253\346\211\200\346\234\211\344\270\211\347\247\215\345\255\227\347\254\246\347\232\204\345\255\220\345\255\227\347\254\246\344\270\262\346\225\260\347\233\256.md" "b/Solutions/1358. \345\214\205\345\220\253\346\211\200\346\234\211\344\270\211\347\247\215\345\255\227\347\254\246\347\232\204\345\255\220\345\255\227\347\254\246\344\270\262\346\225\260\347\233\256.md"
index 0f94d488..61652253 100644
--- "a/Solutions/1358. \345\214\205\345\220\253\346\211\200\346\234\211\344\270\211\347\247\215\345\255\227\347\254\246\347\232\204\345\255\220\345\255\227\347\254\246\344\270\262\346\225\260\347\233\256.md"
+++ "b/Solutions/1358. \345\214\205\345\220\253\346\211\200\346\234\211\344\270\211\347\247\215\345\255\227\347\254\246\347\232\204\345\255\220\345\255\227\347\254\246\344\270\262\346\225\260\347\233\256.md"
@@ -25,7 +25,7 @@
## 代码
-```Python
+```python
class Solution:
def numberOfSubstrings(self, s: str) -> int:
window = dict()
diff --git "a/Solutions/1381. \350\256\276\350\256\241\344\270\200\344\270\252\346\224\257\346\214\201\345\242\236\351\207\217\346\223\215\344\275\234\347\232\204\346\240\210.md" "b/Solutions/1381. \350\256\276\350\256\241\344\270\200\344\270\252\346\224\257\346\214\201\345\242\236\351\207\217\346\223\215\344\275\234\347\232\204\346\240\210.md"
index 12c65e0c..5eabdd7c 100644
--- "a/Solutions/1381. \350\256\276\350\256\241\344\270\200\344\270\252\346\224\257\346\214\201\345\242\236\351\207\217\346\223\215\344\275\234\347\232\204\346\240\210.md"
+++ "b/Solutions/1381. \350\256\276\350\256\241\344\270\200\344\270\252\346\224\257\346\214\201\345\242\236\351\207\217\346\223\215\344\275\234\347\232\204\346\240\210.md"
@@ -24,7 +24,7 @@
- 示例 1:
-```Python
+```python
输入:
["CustomStack","push","push","pop","push","push","push","increment","increment","pop","pop","pop","pop"]
[[3],[1],[2],[],[2],[3],[4],[5,100],[2,100],[],[],[],[]]
@@ -71,7 +71,7 @@ stk.pop(); // 返回 -1 --> 栈为空,返回 -1
### 思路 1:代码
-```Python
+```python
class CustomStack:
def __init__(self, maxSize: int):
diff --git "a/Solutions/1400. \346\236\204\351\200\240 K \344\270\252\345\233\236\346\226\207\345\255\227\347\254\246\344\270\262.md" "b/Solutions/1400. \346\236\204\351\200\240 K \344\270\252\345\233\236\346\226\207\345\255\227\347\254\246\344\270\262.md"
index 33d691bd..d31589fd 100644
--- "a/Solutions/1400. \346\236\204\351\200\240 K \344\270\252\345\233\236\346\226\207\345\255\227\347\254\246\344\270\262.md"
+++ "b/Solutions/1400. \346\236\204\351\200\240 K \344\270\252\345\233\236\346\226\207\345\255\227\347\254\246\344\270\262.md"
@@ -19,7 +19,7 @@
- 示例 1:
-```Python
+```python
输入:s = "annabelle", k = 2
输出:True
解释:可以用 s 中所有字符构造 2 个回文字符串。
@@ -36,7 +36,7 @@
### 思路 1:贪心算法代码
-```Python
+```python
import collections
class Solution:
diff --git "a/Solutions/1408. \346\225\260\347\273\204\344\270\255\347\232\204\345\255\227\347\254\246\344\270\262\345\214\271\351\205\215.md" "b/Solutions/1408. \346\225\260\347\273\204\344\270\255\347\232\204\345\255\227\347\254\246\344\270\262\345\214\271\351\205\215.md"
index 8e6439d0..ffc9ea52 100644
--- "a/Solutions/1408. \346\225\260\347\273\204\344\270\255\347\232\204\345\255\227\347\254\246\344\270\262\345\214\271\351\205\215.md"
+++ "b/Solutions/1408. \346\225\260\347\273\204\344\270\255\347\232\204\345\255\227\347\254\246\344\270\262\345\214\271\351\205\215.md"
@@ -20,7 +20,7 @@
- 示例 1:
-```Python
+```python
输入:words = ["mass","as","hero","superhero"]
输出:["as","hero"]
解释:"as" 是 "mass" 的子字符串,"hero" 是 "superhero" 的子字符串。此外,["hero","as"] 也是有效的答案。
@@ -36,7 +36,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
# 生成 next 数组
# next[j] 表示下标 j 之前的模式串 p 中,最长相等前后缀的长度
diff --git "a/Solutions/1422. \345\210\206\345\211\262\345\255\227\347\254\246\344\270\262\347\232\204\346\234\200\345\244\247\345\276\227\345\210\206.md" "b/Solutions/1422. \345\210\206\345\211\262\345\255\227\347\254\246\344\270\262\347\232\204\346\234\200\345\244\247\345\276\227\345\210\206.md"
index 1f76bd12..e6d29a01 100644
--- "a/Solutions/1422. \345\210\206\345\211\262\345\255\227\347\254\246\344\270\262\347\232\204\346\234\200\345\244\247\345\276\227\345\210\206.md"
+++ "b/Solutions/1422. \345\210\206\345\211\262\345\255\227\347\254\246\344\270\262\347\232\204\346\234\200\345\244\247\345\276\227\345\210\206.md"
@@ -18,7 +18,7 @@
- 示例 1:
-```Python
+```python
输入:s = "011101"
输出:5
解释:
@@ -32,7 +32,7 @@
- 示例 2:
-```Python
+```python
输入:s = "00111"
输出:5
解释:当 左子字符串 = "00" 且 右子字符串 = "111" 时,我们得到最大得分 = 2 + 3 = 5
@@ -48,7 +48,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def maxScore(self, s: str) -> int:
size = len(s)
diff --git "a/Solutions/1423. \345\217\257\350\216\267\345\276\227\347\232\204\346\234\200\345\244\247\347\202\271\346\225\260.md" "b/Solutions/1423. \345\217\257\350\216\267\345\276\227\347\232\204\346\234\200\345\244\247\347\202\271\346\225\260.md"
index 81190242..e5d7eae1 100644
--- "a/Solutions/1423. \345\217\257\350\216\267\345\276\227\347\232\204\346\234\200\345\244\247\347\202\271\346\225\260.md"
+++ "b/Solutions/1423. \345\217\257\350\216\267\345\276\227\347\232\204\346\234\200\345\244\247\347\202\271\346\225\260.md"
@@ -31,7 +31,7 @@
## 代码
-```Python
+```python
class Solution:
def maxScore(self, cardPoints: List[int], k: int) -> int:
window_size = len(cardPoints) - k
diff --git "a/Solutions/1438. \347\273\235\345\257\271\345\267\256\344\270\215\350\266\205\350\277\207\351\231\220\345\210\266\347\232\204\346\234\200\351\225\277\350\277\236\347\273\255\345\255\220\346\225\260\347\273\204.md" "b/Solutions/1438. \347\273\235\345\257\271\345\267\256\344\270\215\350\266\205\350\277\207\351\231\220\345\210\266\347\232\204\346\234\200\351\225\277\350\277\236\347\273\255\345\255\220\346\225\260\347\273\204.md"
index 07dd44b8..100f1814 100644
--- "a/Solutions/1438. \347\273\235\345\257\271\345\267\256\344\270\215\350\266\205\350\277\207\351\231\220\345\210\266\347\232\204\346\234\200\351\225\277\350\277\236\347\273\255\345\255\220\346\225\260\347\273\204.md"
+++ "b/Solutions/1438. \347\273\235\345\257\271\345\267\256\344\270\215\350\266\205\350\277\207\351\231\220\345\210\266\347\232\204\346\234\200\351\225\277\350\277\236\347\273\255\345\255\220\346\225\260\347\273\204.md"
@@ -25,7 +25,7 @@
## 代码
-```Python
+```python
import heapq
class Solution:
diff --git "a/Solutions/1446. \350\277\236\347\273\255\345\255\227\347\254\246.md" "b/Solutions/1446. \350\277\236\347\273\255\345\255\227\347\254\246.md"
index 4f02b055..4e125760 100644
--- "a/Solutions/1446. \350\277\236\347\273\255\345\255\227\347\254\246.md"
+++ "b/Solutions/1446. \350\277\236\347\273\255\345\255\227\347\254\246.md"
@@ -20,7 +20,7 @@
## 代码
-```Python
+```python
class Solution:
def maxPower(self, s: str) -> int:
ans = 1
diff --git "a/Solutions/1447. \346\234\200\347\256\200\345\210\206\346\225\260.md" "b/Solutions/1447. \346\234\200\347\256\200\345\210\206\346\225\260.md"
index 0465f2b5..f81f7e4a 100644
--- "a/Solutions/1447. \346\234\200\347\256\200\345\210\206\346\225\260.md"
+++ "b/Solutions/1447. \346\234\200\347\256\200\345\210\206\346\225\260.md"
@@ -17,7 +17,7 @@
- 示例 1:
-```Python
+```python
输入:n = 2
输出:["1/2"]
解释:"1/2" 是唯一一个分母小于等于 2 的最简分数。
@@ -25,7 +25,7 @@
- 示例 2:
-```Python
+```python
输入:n = 4
输出:["1/2","1/3","1/4","2/3","3/4"]
解释:"2/4" 不是最简分数,因为它可以化简为 "1/2"。
@@ -41,7 +41,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def simplifiedFractions(self, n: int) -> List[str]:
res = []
diff --git "a/Solutions/1449. \346\225\260\344\275\215\346\210\220\346\234\254\345\222\214\344\270\272\347\233\256\346\240\207\345\200\274\347\232\204\346\234\200\345\244\247\346\225\260\345\255\227.md" "b/Solutions/1449. \346\225\260\344\275\215\346\210\220\346\234\254\345\222\214\344\270\272\347\233\256\346\240\207\345\200\274\347\232\204\346\234\200\345\244\247\346\225\260\345\255\227.md"
index 0adcd960..8a5859e0 100644
--- "a/Solutions/1449. \346\225\260\344\275\215\346\210\220\346\234\254\345\222\214\344\270\272\347\233\256\346\240\207\345\200\274\347\232\204\346\234\200\345\244\247\346\225\260\345\255\227.md"
+++ "b/Solutions/1449. \346\225\260\344\275\215\346\210\220\346\234\254\345\222\214\344\270\272\347\233\256\346\240\207\345\200\274\347\232\204\346\234\200\345\244\247\346\225\260\345\255\227.md"
@@ -25,7 +25,7 @@
- 示例 1:
-```Python
+```python
输入:cost = [4,3,2,5,6,7,2,5,5], target = 9
输出:"7772"
解释:添加数位 '7' 的成本为 2 ,添加数位 '2' 的成本为 3 。所以 "7772" 的代价为 2*3+ 3*1 = 9 。 "977" 也是满足要求的数字,但 "7772" 是较大的数字。
@@ -43,7 +43,7 @@
- 示例 2:
-```Python
+```python
输入:cost = [7,6,5,5,5,6,8,7,8], target = 12
输出:"85"
解释:添加数位 '8' 的成本是 7 ,添加数位 '5' 的成本是 5 。"85" 的成本为 7 + 5 = 12。
@@ -90,7 +90,7 @@ $dp[w] = maxInt(dp[w], str(i) + dp[w - cost[i - 1]])$
### 思路 1:代码
-```Python
+```python
class Solution:
def largestNumber(self, cost: List[int], target: int) -> str:
def maxInt(a, b):
diff --git "a/Solutions/1450. \345\234\250\346\227\242\345\256\232\346\227\266\351\227\264\345\201\232\344\275\234\344\270\232\347\232\204\345\255\246\347\224\237\344\272\272\346\225\260.md" "b/Solutions/1450. \345\234\250\346\227\242\345\256\232\346\227\266\351\227\264\345\201\232\344\275\234\344\270\232\347\232\204\345\255\246\347\224\237\344\272\272\346\225\260.md"
index 20b618b1..0a94a339 100644
--- "a/Solutions/1450. \345\234\250\346\227\242\345\256\232\346\227\266\351\227\264\345\201\232\344\275\234\344\270\232\347\232\204\345\255\246\347\224\237\344\272\272\346\225\260.md"
+++ "b/Solutions/1450. \345\234\250\346\227\242\345\256\232\346\227\266\351\227\264\345\201\232\344\275\234\344\270\232\347\232\204\345\255\246\347\224\237\344\272\272\346\225\260.md"
@@ -20,7 +20,7 @@
- 示例 1:
-```Python
+```python
输入:startTime = [4], endTime = [4], queryTime = 4
输出:1
解释:在查询时间只有一名学生在做作业。
@@ -36,7 +36,7 @@
### 思路 1:枚举算法代码
-```Python
+```python
class Solution:
def busyStudent(self, startTime: List[int], endTime: List[int], queryTime: int) -> int:
cnt = 0
@@ -55,7 +55,7 @@ class Solution:
### 思路 2:线段树代码
-```Python
+```python
# 线段树的节点类
class SegTreeNode:
def __init__(self, val=0):
@@ -239,7 +239,7 @@ class Solution:
### 思路 3:树状数组代码
-```Python
+```python
class BinaryIndexTree:
def __init__(self, n):
diff --git "a/Solutions/1456. \345\256\232\351\225\277\345\255\220\344\270\262\344\270\255\345\205\203\351\237\263\347\232\204\346\234\200\345\244\247\346\225\260\347\233\256.md" "b/Solutions/1456. \345\256\232\351\225\277\345\255\220\344\270\262\344\270\255\345\205\203\351\237\263\347\232\204\346\234\200\345\244\247\346\225\260\347\233\256.md"
index 0e730416..6424f7a9 100644
--- "a/Solutions/1456. \345\256\232\351\225\277\345\255\220\344\270\262\344\270\255\345\205\203\351\237\263\347\232\204\346\234\200\345\244\247\346\225\260\347\233\256.md"
+++ "b/Solutions/1456. \345\256\232\351\225\277\345\255\220\344\270\262\344\270\255\345\205\203\351\237\263\347\232\204\346\234\200\345\244\247\346\225\260\347\233\256.md"
@@ -24,7 +24,7 @@
## 代码
-```Python
+```python
class Solution:
def maxVowels(self, s: str, k: int) -> int:
left, right = 0, 0
diff --git "a/Solutions/1480. \344\270\200\347\273\264\346\225\260\347\273\204\347\232\204\345\212\250\346\200\201\345\222\214.md" "b/Solutions/1480. \344\270\200\347\273\264\346\225\260\347\273\204\347\232\204\345\212\250\346\200\201\345\222\214.md"
index a9c48bf8..b366bd8b 100644
--- "a/Solutions/1480. \344\270\200\347\273\264\346\225\260\347\273\204\347\232\204\345\212\250\346\200\201\345\222\214.md"
+++ "b/Solutions/1480. \344\270\200\347\273\264\346\225\260\347\273\204\347\232\204\345\212\250\346\200\201\345\222\214.md"
@@ -17,7 +17,7 @@
- 示例 1:
-```Python
+```python
输入:nums = [1,2,3,4]
输出:[1,3,6,10]
解释:动态和计算过程为 [1, 1+2, 1+2+3, 1+2+3+4]。
@@ -25,7 +25,7 @@
- 示例 2:
-```Python
+```python
输入:nums = [1,1,1,1,1]
输出:[1,2,3,4,5]
解释:动态和计算过程为 [1, 1+1, 1+1+1, 1+1+1+1, 1+1+1+1+1]。
@@ -48,7 +48,7 @@ $runningSum = \begin{cases} nums[0], & i = 0 \cr runningSum[i - 1] + nums[i], &
### 思路 1:代码
-```Python
+```python
class Solution:
def runningSum(self, nums: List[int]) -> List[int]:
size = len(nums)
diff --git "a/Solutions/1482. \345\210\266\344\275\234 m \346\235\237\350\212\261\346\211\200\351\234\200\347\232\204\346\234\200\345\260\221\345\244\251\346\225\260.md" "b/Solutions/1482. \345\210\266\344\275\234 m \346\235\237\350\212\261\346\211\200\351\234\200\347\232\204\346\234\200\345\260\221\345\244\251\346\225\260.md"
index 673f1646..6615d1b1 100644
--- "a/Solutions/1482. \345\210\266\344\275\234 m \346\235\237\350\212\261\346\211\200\351\234\200\347\232\204\346\234\200\345\260\221\345\244\251\346\225\260.md"
+++ "b/Solutions/1482. \345\210\266\344\275\234 m \346\235\237\350\212\261\346\211\200\351\234\200\347\232\204\346\234\200\345\260\221\345\244\251\346\225\260.md"
@@ -40,7 +40,7 @@
## 代码
-```Python
+```python
class Solution:
def canMake(self, bloomDay, days, m, k):
count = 0
diff --git "a/Solutions/1486. \346\225\260\347\273\204\345\274\202\346\210\226\346\223\215\344\275\234.md" "b/Solutions/1486. \346\225\260\347\273\204\345\274\202\346\210\226\346\223\215\344\275\234.md"
index 9f708b22..cfcd95f9 100644
--- "a/Solutions/1486. \346\225\260\347\273\204\345\274\202\346\210\226\346\223\215\344\275\234.md"
+++ "b/Solutions/1486. \346\225\260\347\273\204\345\274\202\346\210\226\346\223\215\344\275\234.md"
@@ -54,7 +54,7 @@ $sumXor(x) = \begin{cases} \begin{array} \ x, & x = 4i, k \in Z \cr 1, & x = 4i+
1. 模拟
-```Python
+```python
class Solution:
def xorOperation(self, n: int, start: int) -> int:
ans = 0
@@ -65,7 +65,7 @@ class Solution:
2. 规律
-```Python
+```python
class Solution:
def sumXor(self, x):
if x % 4 == 0:
diff --git "a/Solutions/1491. \345\216\273\346\216\211\346\234\200\344\275\216\345\267\245\350\265\204\345\222\214\346\234\200\351\253\230\345\267\245\350\265\204\345\220\216\347\232\204\345\267\245\350\265\204\345\271\263\345\235\207\345\200\274.md" "b/Solutions/1491. \345\216\273\346\216\211\346\234\200\344\275\216\345\267\245\350\265\204\345\222\214\346\234\200\351\253\230\345\267\245\350\265\204\345\220\216\347\232\204\345\267\245\350\265\204\345\271\263\345\235\207\345\200\274.md"
index 0af6c31f..c5bbf47a 100644
--- "a/Solutions/1491. \345\216\273\346\216\211\346\234\200\344\275\216\345\267\245\350\265\204\345\222\214\346\234\200\351\253\230\345\267\245\350\265\204\345\220\216\347\232\204\345\267\245\350\265\204\345\271\263\345\235\207\345\200\274.md"
+++ "b/Solutions/1491. \345\216\273\346\216\211\346\234\200\344\275\216\345\267\245\350\265\204\345\222\214\346\234\200\351\253\230\345\267\245\350\265\204\345\220\216\347\232\204\345\267\245\350\265\204\345\271\263\345\235\207\345\200\274.md"
@@ -20,7 +20,7 @@
- 示例 1:
-```Python
+```python
给定 salary = [1000,2000,3000]
输出 2000.00000
解释 最低工资为 1000,最高工资为 3000,去除最低工资和最高工资之后,剩下员工工资的平均值为 2000 / 1 = 2000
@@ -41,7 +41,7 @@
### 思路 1 代码:
-```Python
+```python
class Solution:
def average(self, salary: List[int]) -> float:
min_s, max_s = min(salary), max(salary)
diff --git "a/Solutions/1493. \345\210\240\346\216\211\344\270\200\344\270\252\345\205\203\347\264\240\344\273\245\345\220\216\345\205\250\344\270\272 1 \347\232\204\346\234\200\351\225\277\345\255\220\346\225\260\347\273\204.md" "b/Solutions/1493. \345\210\240\346\216\211\344\270\200\344\270\252\345\205\203\347\264\240\344\273\245\345\220\216\345\205\250\344\270\272 1 \347\232\204\346\234\200\351\225\277\345\255\220\346\225\260\347\273\204.md"
index 847059aa..b99a1782 100644
--- "a/Solutions/1493. \345\210\240\346\216\211\344\270\200\344\270\252\345\205\203\347\264\240\344\273\245\345\220\216\345\205\250\344\270\272 1 \347\232\204\346\234\200\351\225\277\345\255\220\346\225\260\347\273\204.md"
+++ "b/Solutions/1493. \345\210\240\346\216\211\344\270\200\344\270\252\345\205\203\347\264\240\344\273\245\345\220\216\345\205\250\344\270\272 1 \347\232\204\346\234\200\351\225\277\345\255\220\346\225\260\347\273\204.md"
@@ -25,7 +25,7 @@
## 代码
-```Python
+```python
class Solution:
def longestSubarray(self, nums: List[int]) -> int:
left, right = 0, 0
diff --git "a/Solutions/1502. \345\210\244\346\226\255\350\203\275\345\220\246\345\275\242\346\210\220\347\255\211\345\267\256\346\225\260\345\210\227.md" "b/Solutions/1502. \345\210\244\346\226\255\350\203\275\345\220\246\345\275\242\346\210\220\347\255\211\345\267\256\346\225\260\345\210\227.md"
index ecd4c77f..523a95d7 100644
--- "a/Solutions/1502. \345\210\244\346\226\255\350\203\275\345\220\246\345\275\242\346\210\220\347\255\211\345\267\256\346\225\260\345\210\227.md"
+++ "b/Solutions/1502. \345\210\244\346\226\255\350\203\275\345\220\246\345\275\242\346\210\220\347\255\211\345\267\256\346\225\260\345\210\227.md"
@@ -18,7 +18,7 @@
- 示例 1:
-```Python
+```python
输入:arr = [3,5,1]
输出:True
解释:数组重新排序后得到 [1,3,5] 或者 [5,3,1],任意相邻两项的差分别为 2 或 -2 ,可以形成等差数列。
@@ -37,7 +37,7 @@
### 思路 1 代码:
-```Python
+```python
class Solution:
def canMakeArithmeticProgression(self, arr: List[int]) -> bool:
size = len(arr)
diff --git "a/Solutions/1507. \350\275\254\345\217\230\346\227\245\346\234\237\346\240\274\345\274\217.md" "b/Solutions/1507. \350\275\254\345\217\230\346\227\245\346\234\237\346\240\274\345\274\217.md"
index a6f9fcf4..33e04697 100644
--- "a/Solutions/1507. \350\275\254\345\217\230\346\227\245\346\234\237\346\240\274\345\274\217.md"
+++ "b/Solutions/1507. \350\275\254\345\217\230\346\227\245\346\234\237\346\240\274\345\274\217.md"
@@ -25,14 +25,14 @@
- 示例 1:
-```Python
+```python
输入:date = "20th Oct 2052"
输出:"2052-10-20"
```
- 示例 2:
-```Python
+```python
输入:date = "6th Jun 1933"
输出:"1933-06-06"
```
@@ -49,7 +49,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def reformatDate(self, date: str) -> str:
months = {
diff --git "a/Solutions/1523. \345\234\250\345\214\272\351\227\264\350\214\203\345\233\264\345\206\205\347\273\237\350\256\241\345\245\207\346\225\260\346\225\260\347\233\256.md" "b/Solutions/1523. \345\234\250\345\214\272\351\227\264\350\214\203\345\233\264\345\206\205\347\273\237\350\256\241\345\245\207\346\225\260\346\225\260\347\233\256.md"
index 6dbee687..05e35d92 100644
--- "a/Solutions/1523. \345\234\250\345\214\272\351\227\264\350\214\203\345\233\264\345\206\205\347\273\237\350\256\241\345\245\207\346\225\260\346\225\260\347\233\256.md"
+++ "b/Solutions/1523. \345\234\250\345\214\272\351\227\264\350\214\203\345\233\264\345\206\205\347\273\237\350\256\241\345\245\207\346\225\260\346\225\260\347\233\256.md"
@@ -17,7 +17,7 @@
- 示例 1:
-```Python
+```python
输入:low = 3, high = 7
输出:3
解释:3 到 7 之间奇数数字为 [3,5,7]
@@ -35,7 +35,7 @@
### 思路 1 代码:
-```Python
+```python
class Solution:
def pre(self, val):
return (val + 1) >> 1
diff --git "a/Solutions/1534. \347\273\237\350\256\241\345\245\275\344\270\211\345\205\203\347\273\204.md" "b/Solutions/1534. \347\273\237\350\256\241\345\245\275\344\270\211\345\205\203\347\273\204.md"
index 6e61b2b4..34311f48 100644
--- "a/Solutions/1534. \347\273\237\350\256\241\345\245\275\344\270\211\345\205\203\347\273\204.md"
+++ "b/Solutions/1534. \347\273\237\350\256\241\345\245\275\344\270\211\345\205\203\347\273\204.md"
@@ -25,7 +25,7 @@
- 示例 1:
-```Python
+```python
输入:arr = [3,0,1,1,9,7], a = 7, b = 2, c = 3
输出:4
解释:一共有 4 个好三元组:[(3,0,1), (3,0,1), (3,1,1), (0,1,1)]。
@@ -33,7 +33,7 @@
- 示例 2:
-```Python
+```python
输入:arr = [1,1,2,2,3], a = 0, b = 0, c = 1
输出:0
解释:不存在满足所有条件的三元组。
@@ -48,7 +48,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def countGoodTriplets(self, arr: List[int], a: int, b: int, c: int) -> int:
size = len(arr)
diff --git "a/Solutions/1547. \345\210\207\346\243\215\345\255\220\347\232\204\346\234\200\345\260\217\346\210\220\346\234\254.md" "b/Solutions/1547. \345\210\207\346\243\215\345\255\220\347\232\204\346\234\200\345\260\217\346\210\220\346\234\254.md"
index 001c25f7..eb0c67fe 100644
--- "a/Solutions/1547. \345\210\207\346\243\215\345\255\220\347\232\204\346\234\200\345\260\217\346\210\220\346\234\254.md"
+++ "b/Solutions/1547. \345\210\207\346\243\215\345\255\220\347\232\204\346\234\200\345\260\217\346\210\220\346\234\254.md"
@@ -30,7 +30,7 @@

-```Python
+```python
输入:n = 7, cuts = [1,3,4,5]
输出:16
解释:按 [1, 3, 4, 5] 的顺序切割的情况如下所示。
@@ -41,7 +41,7 @@
- 示例 2:
-```Python
+```python
输入:n = 9, cuts = [5,6,1,4,2]
输出:22
解释:如果按给定的顺序切割,则总成本为 25。总成本 <= 25 的切割顺序很多,例如,[4, 6, 5, 2, 1] 的总成本 = 22,是所有可能方案中成本最小的。
@@ -80,7 +80,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def minCost(self, n: int, cuts: List[int]) -> int:
cuts.append(0)
diff --git "a/Solutions/1551. \344\275\277\346\225\260\347\273\204\344\270\255\346\211\200\346\234\211\345\205\203\347\264\240\347\233\270\347\255\211\347\232\204\346\234\200\345\260\217\346\223\215\344\275\234\346\225\260.md" "b/Solutions/1551. \344\275\277\346\225\260\347\273\204\344\270\255\346\211\200\346\234\211\345\205\203\347\264\240\347\233\270\347\255\211\347\232\204\346\234\200\345\260\217\346\223\215\344\275\234\346\225\260.md"
index 4603d73c..485dbc83 100644
--- "a/Solutions/1551. \344\275\277\346\225\260\347\273\204\344\270\255\346\211\200\346\234\211\345\205\203\347\264\240\347\233\270\347\255\211\347\232\204\346\234\200\345\260\217\346\223\215\344\275\234\346\225\260.md"
+++ "b/Solutions/1551. \344\275\277\346\225\260\347\273\204\344\270\255\346\211\200\346\234\211\345\205\203\347\264\240\347\233\270\347\255\211\347\232\204\346\234\200\345\260\217\346\223\215\344\275\234\346\225\260.md"
@@ -22,7 +22,7 @@
- 示例 1:
-```Python
+```python
输入:n = 3
输出:2
解释:arr = [1, 3, 5]
@@ -32,7 +32,7 @@
- 示例 2:
-```Python
+```python
输入:n = 6
输出:9
```
@@ -47,7 +47,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def minOperations(self, n: int) -> int:
ans = 0
@@ -69,7 +69,7 @@ $\lbrace n - 1 + [n - 1 - 2 * (n \div 2 - 1)]\rbrace \times (n \div 2) \div 2 =
### 思路 2:代码
-```Python
+```python
class Solution:
def minOperations(self, n: int) -> int:
return n * n // 4
diff --git "a/Solutions/1556. \345\215\203\344\275\215\345\210\206\351\232\224\346\225\260.md" "b/Solutions/1556. \345\215\203\344\275\215\345\210\206\351\232\224\346\225\260.md"
index 69e2aaba..97de9a07 100644
--- "a/Solutions/1556. \345\215\203\344\275\215\345\210\206\351\232\224\346\225\260.md"
+++ "b/Solutions/1556. \345\215\203\344\275\215\345\210\206\351\232\224\346\225\260.md"
@@ -17,14 +17,14 @@
- 示例 1:
-```Python
+```python
输入:n = 987
输出:"987"
```
- 示例 2:
-```Python
+```python
输入:n = 123456789
输出:"123.456.789"
```
@@ -40,7 +40,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def thousandSeparator(self, n: int) -> str:
s = str(n)
diff --git "a/Solutions/1561. \344\275\240\345\217\257\344\273\245\350\216\267\345\276\227\347\232\204\346\234\200\345\244\247\347\241\254\345\270\201\346\225\260\347\233\256.md" "b/Solutions/1561. \344\275\240\345\217\257\344\273\245\350\216\267\345\276\227\347\232\204\346\234\200\345\244\247\347\241\254\345\270\201\346\225\260\347\233\256.md"
index 10186c2f..fd8ae3ed 100644
--- "a/Solutions/1561. \344\275\240\345\217\257\344\273\245\350\216\267\345\276\227\347\232\204\346\234\200\345\244\247\347\241\254\345\270\201\346\225\260\347\233\256.md"
+++ "b/Solutions/1561. \344\275\240\345\217\257\344\273\245\350\216\267\345\276\227\347\232\204\346\234\200\345\244\247\347\241\254\345\270\201\346\225\260\347\233\256.md"
@@ -29,7 +29,7 @@
## 代码
-```Python
+```python
class Solution:
def maxCoins(self, piles: List[int]) -> int:
piles.sort()
diff --git "a/Solutions/1567. \344\271\230\347\247\257\344\270\272\346\255\243\346\225\260\347\232\204\346\234\200\351\225\277\345\255\220\346\225\260\347\273\204\351\225\277\345\272\246.md" "b/Solutions/1567. \344\271\230\347\247\257\344\270\272\346\255\243\346\225\260\347\232\204\346\234\200\351\225\277\345\255\220\346\225\260\347\273\204\351\225\277\345\272\246.md"
index cb3bcbe3..223a764c 100644
--- "a/Solutions/1567. \344\271\230\347\247\257\344\270\272\346\255\243\346\225\260\347\232\204\346\234\200\351\225\277\345\255\220\346\225\260\347\273\204\351\225\277\345\272\246.md"
+++ "b/Solutions/1567. \344\271\230\347\247\257\344\270\272\346\255\243\346\225\260\347\232\204\346\234\200\351\225\277\345\255\220\346\225\260\347\273\204\351\225\277\345\272\246.md"
@@ -33,7 +33,7 @@
## 代码
-```Python
+```python
class Solution:
def getMaxLen(self, nums: List[int]) -> int:
size = len(nums)
diff --git "a/Solutions/1593. \346\213\206\345\210\206\345\255\227\347\254\246\344\270\262\344\275\277\345\224\257\344\270\200\345\255\220\345\255\227\347\254\246\344\270\262\347\232\204\346\225\260\347\233\256\346\234\200\345\244\247.md" "b/Solutions/1593. \346\213\206\345\210\206\345\255\227\347\254\246\344\270\262\344\275\277\345\224\257\344\270\200\345\255\220\345\255\227\347\254\246\344\270\262\347\232\204\346\225\260\347\233\256\346\234\200\345\244\247.md"
index 19715184..9a113a2e 100644
--- "a/Solutions/1593. \346\213\206\345\210\206\345\255\227\347\254\246\344\270\262\344\275\277\345\224\257\344\270\200\345\255\220\345\255\227\347\254\246\344\270\262\347\232\204\346\225\260\347\233\256\346\234\200\345\244\247.md"
+++ "b/Solutions/1593. \346\213\206\345\210\206\345\255\227\347\254\246\344\270\262\344\275\277\345\224\257\344\270\200\345\255\220\345\255\227\347\254\246\344\270\262\347\232\204\346\225\260\347\233\256\346\234\200\345\244\247.md"
@@ -26,7 +26,7 @@
## 代码
-```Python
+```python
class Solution:
ans = 0
def backtrack(self, s, index, count, s_set):
diff --git "a/Solutions/1595. \350\277\236\351\200\232\344\270\244\347\273\204\347\202\271\347\232\204\346\234\200\345\260\217\346\210\220\346\234\254.md" "b/Solutions/1595. \350\277\236\351\200\232\344\270\244\347\273\204\347\202\271\347\232\204\346\234\200\345\260\217\346\210\220\346\234\254.md"
index d02a8763..879b7ae5 100644
--- "a/Solutions/1595. \350\277\236\351\200\232\344\270\244\347\273\204\347\202\271\347\232\204\346\234\200\345\260\217\346\210\220\346\234\254.md"
+++ "b/Solutions/1595. \350\277\236\351\200\232\344\270\244\347\273\204\347\202\271\347\232\204\346\234\200\345\260\217\346\210\220\346\234\254.md"
@@ -25,7 +25,7 @@

-```Python
+```python
输入:cost = [[15, 96], [36, 2]]
输出:17
解释:连通两组点的最佳方法是:
@@ -38,7 +38,7 @@

-```Python
+```python
输入:cost = [[1, 3, 5], [4, 1, 1], [1, 5, 3]]
输出:4
解释:连通两组点的最佳方法是:
@@ -58,7 +58,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def connectTwoGroups(self, cost: List[List[int]]) -> int:
m, n = len(cost), len(cost[0])
diff --git "a/Solutions/1603. \350\256\276\350\256\241\345\201\234\350\275\246\347\263\273\347\273\237.md" "b/Solutions/1603. \350\256\276\350\256\241\345\201\234\350\275\246\347\263\273\347\273\237.md"
index 0a00d28d..d09f72cd 100644
--- "a/Solutions/1603. \350\256\276\350\256\241\345\201\234\350\275\246\347\263\273\347\273\237.md"
+++ "b/Solutions/1603. \350\256\276\350\256\241\345\201\234\350\275\246\347\263\273\347\273\237.md"
@@ -18,7 +18,7 @@
## 代码
-```Python
+```python
class ParkingSystem:
def __init__(self, big: int, medium: int, small: int):
diff --git "a/Solutions/1605. \347\273\231\345\256\232\350\241\214\345\222\214\345\210\227\347\232\204\345\222\214\346\261\202\345\217\257\350\241\214\347\237\251\351\230\265.md" "b/Solutions/1605. \347\273\231\345\256\232\350\241\214\345\222\214\345\210\227\347\232\204\345\222\214\346\261\202\345\217\257\350\241\214\347\237\251\351\230\265.md"
index 5cb9028b..fd3c48ea 100644
--- "a/Solutions/1605. \347\273\231\345\256\232\350\241\214\345\222\214\345\210\227\347\232\204\345\222\214\346\261\202\345\217\257\350\241\214\347\237\251\351\230\265.md"
+++ "b/Solutions/1605. \347\273\231\345\256\232\350\241\214\345\222\214\345\210\227\347\232\204\345\222\214\346\261\202\345\217\257\350\241\214\347\237\251\351\230\265.md"
@@ -20,7 +20,7 @@
- 示例 1:
-```Python
+```python
输入:rowSum = [3,8], colSum = [4,7]
输出:[[3,0],
[1,7]]
@@ -49,7 +49,7 @@
### 思路 1:贪心算法代码
-```Python
+```python
class Solution:
def restoreMatrix(self, rowSum: List[int], colSum: List[int]) -> List[List[int]]:
rows, cols = len(rowSum), len(colSum)
diff --git "a/Solutions/1617. \347\273\237\350\256\241\345\255\220\346\240\221\344\270\255\345\237\216\345\270\202\344\271\213\351\227\264\346\234\200\345\244\247\350\267\235\347\246\273.md" "b/Solutions/1617. \347\273\237\350\256\241\345\255\220\346\240\221\344\270\255\345\237\216\345\270\202\344\271\213\351\227\264\346\234\200\345\244\247\350\267\235\347\246\273.md"
index 77b2bb22..6100496d 100644
--- "a/Solutions/1617. \347\273\237\350\256\241\345\255\220\346\240\221\344\270\255\345\237\216\345\270\202\344\271\213\351\227\264\346\234\200\345\244\247\350\267\235\347\246\273.md"
+++ "b/Solutions/1617. \347\273\237\350\256\241\345\255\220\346\240\221\344\270\255\345\237\216\345\270\202\344\271\213\351\227\264\346\234\200\345\244\247\350\267\235\347\246\273.md"
@@ -23,7 +23,7 @@
- 示例 1:
-```Python
+```python
输入:n = 4, edges = [[1,2],[2,3],[2,4]]
输出:[3,4,0]
解释:
@@ -34,7 +34,7 @@
- 示例 2:
-```Python
+```python
输入:n = 2, edges = [[1,2]]
输出:[1]
```
@@ -55,7 +55,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def countSubgraphsForEachDiameter(self, n: int, edges: List[List[int]]) -> List[int]:
graph = [[] for _ in range(n)] # 建图
diff --git "a/Solutions/1631. \346\234\200\345\260\217\344\275\223\345\212\233\346\266\210\350\200\227\350\267\257\345\276\204.md" "b/Solutions/1631. \346\234\200\345\260\217\344\275\223\345\212\233\346\266\210\350\200\227\350\267\257\345\276\204.md"
index 2390a578..3fb02a0b 100644
--- "a/Solutions/1631. \346\234\200\345\260\217\344\275\223\345\212\233\346\266\210\350\200\227\350\267\257\345\276\204.md"
+++ "b/Solutions/1631. \346\234\200\345\260\217\344\275\223\345\212\233\346\266\210\350\200\227\350\267\257\345\276\204.md"
@@ -27,7 +27,7 @@
## 代码
-```Python
+```python
class UnionFind:
def __init__(self, n):
diff --git "a/Solutions/1646. \350\216\267\345\217\226\347\224\237\346\210\220\346\225\260\347\273\204\344\270\255\347\232\204\346\234\200\345\244\247\345\200\274.md" "b/Solutions/1646. \350\216\267\345\217\226\347\224\237\346\210\220\346\225\260\347\273\204\344\270\255\347\232\204\346\234\200\345\244\247\345\200\274.md"
index 60dbfbb8..8358597d 100644
--- "a/Solutions/1646. \350\216\267\345\217\226\347\224\237\346\210\220\346\225\260\347\273\204\344\270\255\347\232\204\346\234\200\345\244\247\345\200\274.md"
+++ "b/Solutions/1646. \350\216\267\345\217\226\347\224\237\346\210\220\346\225\260\347\273\204\344\270\255\347\232\204\346\234\200\345\244\247\345\200\274.md"
@@ -22,7 +22,7 @@
- 示例 1:
-```Python
+```python
输入:n = 7
输出:3
解释:根据规则:
@@ -39,7 +39,7 @@
- 示例 2:
-```Python
+```python
输入:n = 2
输出:1
解释:根据规则,nums[0]、nums[1] 和 nums[2] 之中的最大值是 1
@@ -55,7 +55,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def getMaximumGenerated(self, n: int) -> int:
if n <= 1:
diff --git "a/Solutions/1658. \345\260\206 x \345\207\217\345\210\260 0 \347\232\204\346\234\200\345\260\217\346\223\215\344\275\234\346\225\260.md" "b/Solutions/1658. \345\260\206 x \345\207\217\345\210\260 0 \347\232\204\346\234\200\345\260\217\346\223\215\344\275\234\346\225\260.md"
index 311b02c1..8244e574 100644
--- "a/Solutions/1658. \345\260\206 x \345\207\217\345\210\260 0 \347\232\204\346\234\200\345\260\217\346\223\215\344\275\234\346\225\260.md"
+++ "b/Solutions/1658. \345\260\206 x \345\207\217\345\210\260 0 \347\232\204\346\234\200\345\260\217\346\223\215\344\275\234\346\225\260.md"
@@ -25,7 +25,7 @@
## 代码
-```Python
+```python
class Solution:
def minOperations(self, nums: List[int], x: int) -> int:
target = sum(nums) - x
diff --git "a/Solutions/1672. \346\234\200\345\257\214\346\234\211\345\256\242\346\210\267\347\232\204\350\265\204\344\272\247\346\200\273\351\207\217.md" "b/Solutions/1672. \346\234\200\345\257\214\346\234\211\345\256\242\346\210\267\347\232\204\350\265\204\344\272\247\346\200\273\351\207\217.md"
index 886b2a47..5489e758 100644
--- "a/Solutions/1672. \346\234\200\345\257\214\346\234\211\345\256\242\346\210\267\347\232\204\350\265\204\344\272\247\346\200\273\351\207\217.md"
+++ "b/Solutions/1672. \346\234\200\345\257\214\346\234\211\345\256\242\346\210\267\347\232\204\350\265\204\344\272\247\346\200\273\351\207\217.md"
@@ -22,7 +22,7 @@
- 示例 1:
-```Python
+```python
输入:accounts = [[1,2,3],[3,2,1]]
输出:6
解释:
@@ -33,7 +33,7 @@
- 示例 2:
-```Python
+```python
输入:accounts = [[1,5],[7,3],[3,5]]
输出:10
解释:
@@ -54,7 +54,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def maximumWealth(self, accounts: List[List[int]]) -> int:
max_ans = 0
diff --git "a/Solutions/1695. \345\210\240\351\231\244\345\255\220\346\225\260\347\273\204\347\232\204\346\234\200\345\244\247\345\276\227\345\210\206.md" "b/Solutions/1695. \345\210\240\351\231\244\345\255\220\346\225\260\347\273\204\347\232\204\346\234\200\345\244\247\345\276\227\345\210\206.md"
index 30e236c9..7f878721 100644
--- "a/Solutions/1695. \345\210\240\351\231\244\345\255\220\346\225\260\347\273\204\347\232\204\346\234\200\345\244\247\345\276\227\345\210\206.md"
+++ "b/Solutions/1695. \345\210\240\351\231\244\345\255\220\346\225\260\347\273\204\347\232\204\346\234\200\345\244\247\345\276\227\345\210\206.md"
@@ -23,7 +23,7 @@
## 代码
-```Python
+```python
class Solution:
def maximumUniqueSubarray(self, nums: List[int]) -> int:
window_sum = 0
diff --git "a/Solutions/1698. \345\255\227\347\254\246\344\270\262\347\232\204\344\270\215\345\220\214\345\255\220\345\255\227\347\254\246\344\270\262\344\270\252\346\225\260.md" "b/Solutions/1698. \345\255\227\347\254\246\344\270\262\347\232\204\344\270\215\345\220\214\345\255\220\345\255\227\347\254\246\344\270\262\344\270\252\346\225\260.md"
index edb8e9ff..b258b851 100644
--- "a/Solutions/1698. \345\255\227\347\254\246\344\270\262\347\232\204\344\270\215\345\220\214\345\255\220\345\255\227\347\254\246\344\270\262\344\270\252\346\225\260.md"
+++ "b/Solutions/1698. \345\255\227\347\254\246\344\270\262\347\232\204\344\270\215\345\220\214\345\255\220\345\255\227\347\254\246\344\270\262\344\270\252\346\225\260.md"
@@ -21,7 +21,7 @@
## 代码
-```Python
+```python
class Trie:
def __init__(self):
diff --git "a/Solutions/1710. \345\215\241\350\275\246\344\270\212\347\232\204\346\234\200\345\244\247\345\215\225\345\205\203\346\225\260.md" "b/Solutions/1710. \345\215\241\350\275\246\344\270\212\347\232\204\346\234\200\345\244\247\345\215\225\345\205\203\346\225\260.md"
index d78d7978..7de1b5ae 100644
--- "a/Solutions/1710. \345\215\241\350\275\246\344\270\212\347\232\204\346\234\200\345\244\247\345\215\225\345\205\203\346\225\260.md"
+++ "b/Solutions/1710. \345\215\241\350\275\246\344\270\212\347\232\204\346\234\200\345\244\247\345\215\225\345\205\203\346\225\260.md"
@@ -23,7 +23,7 @@
- 示例 1:
-```Python
+```python
输入:boxTypes = [[1,3],[2,2],[3,1]], truckSize = 4
输出:8
解释
@@ -37,7 +37,7 @@
- 示例 2:
-```Python
+```python
输入:boxTypes = [[5,10],[2,5],[4,7],[3,9]], truckSize = 10
输出:91
```
@@ -66,7 +66,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def maximumUnits(self, boxTypes: List[List[int]], truckSize: int) -> int:
boxTypes.sort(key=lambda x:x[1], reverse=True)
diff --git "a/Solutions/1716. \350\256\241\347\256\227\345\212\233\346\211\243\351\223\266\350\241\214\347\232\204\351\222\261.md" "b/Solutions/1716. \350\256\241\347\256\227\345\212\233\346\211\243\351\223\266\350\241\214\347\232\204\351\222\261.md"
index 0f97e390..a7f16813 100644
--- "a/Solutions/1716. \350\256\241\347\256\227\345\212\233\346\211\243\351\223\266\350\241\214\347\232\204\351\222\261.md"
+++ "b/Solutions/1716. \350\256\241\347\256\227\345\212\233\346\211\243\351\223\266\350\241\214\347\232\204\351\222\261.md"
@@ -21,7 +21,7 @@
- 示例 1:
-```Python
+```python
输入:n = 4
输出:10
解释:第 4 天后,总额为 1 + 2 + 3 + 4 = 10。
@@ -29,7 +29,7 @@
- 示例 2:
-```Python
+```python
输入:n = 10
输出:37
解释:第 10 天后,总额为 (1 + 2 + 3 + 4 + 5 + 6 + 7) + (2 + 3 + 4) = 37 。注意到第二个星期一,Hercy 存入 2 块钱。
@@ -45,7 +45,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def totalMoney(self, n: int) -> int:
weak, day = 1, 1
diff --git "a/Solutions/1720. \350\247\243\347\240\201\345\274\202\346\210\226\345\220\216\347\232\204\346\225\260\347\273\204.md" "b/Solutions/1720. \350\247\243\347\240\201\345\274\202\346\210\226\345\220\216\347\232\204\346\225\260\347\273\204.md"
index 3129c510..3fe8195c 100644
--- "a/Solutions/1720. \350\247\243\347\240\201\345\274\202\346\210\226\345\220\216\347\232\204\346\225\260\347\273\204.md"
+++ "b/Solutions/1720. \350\247\243\347\240\201\345\274\202\346\210\226\345\220\216\347\232\204\346\225\260\347\273\204.md"
@@ -29,7 +29,7 @@ n 个非负整数构成数组 arr,经过编码后变为长度为 n-1 的整数
## 代码
-```Python
+```python
class Solution:
def decode(self, encoded: List[int], first: int) -> List[int]:
n = len(encoded) + 1
diff --git "a/Solutions/1736. \346\233\277\346\215\242\351\232\220\350\227\217\346\225\260\345\255\227\345\276\227\345\210\260\347\232\204\346\234\200\346\231\232\346\227\266\351\227\264.md" "b/Solutions/1736. \346\233\277\346\215\242\351\232\220\350\227\217\346\225\260\345\255\227\345\276\227\345\210\260\347\232\204\346\234\200\346\231\232\346\227\266\351\227\264.md"
index 6e8a9f68..3f67c5b0 100644
--- "a/Solutions/1736. \346\233\277\346\215\242\351\232\220\350\227\217\346\225\260\345\255\227\345\276\227\345\210\260\347\232\204\346\234\200\346\231\232\346\227\266\351\227\264.md"
+++ "b/Solutions/1736. \346\233\277\346\215\242\351\232\220\350\227\217\346\225\260\345\255\227\345\276\227\345\210\260\347\232\204\346\234\200\346\231\232\346\227\266\351\227\264.md"
@@ -19,7 +19,7 @@
- 示例 1:
-```Python
+```python
输入:time = "2?:?0"
输出:"23:50"
解释:以数字 '2' 开头的最晚一小时是 23 ,以 '0' 结尾的最晚一分钟是 50。
@@ -27,7 +27,7 @@
- 示例 2:
-```Python
+```python
输入:time = "0?:3?"
输出:"09:39"
```
@@ -51,7 +51,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def maximumTime(self, time: str) -> str:
time_list = list(time)
diff --git "a/Solutions/1742. \347\233\222\345\255\220\344\270\255\345\260\217\347\220\203\347\232\204\346\234\200\345\244\247\346\225\260\351\207\217.md" "b/Solutions/1742. \347\233\222\345\255\220\344\270\255\345\260\217\347\220\203\347\232\204\346\234\200\345\244\247\346\225\260\351\207\217.md"
index 9c392d78..8bc4768e 100644
--- "a/Solutions/1742. \347\233\222\345\255\220\344\270\255\345\260\217\347\220\203\347\232\204\346\234\200\345\244\247\346\225\260\351\207\217.md"
+++ "b/Solutions/1742. \347\233\222\345\255\220\344\270\255\345\260\217\347\220\203\347\232\204\346\234\200\345\244\247\346\225\260\351\207\217.md"
@@ -19,7 +19,7 @@
- 示例 1:
-```Python
+```python
输入:lowLimit = 1, highLimit = 10
输出:2
解释:
@@ -30,7 +30,7 @@
- 示例 2:
-```Python
+```python
输入:lowLimit = 5, highLimit = 15
输出:2
解释:
@@ -74,7 +74,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def countBalls(self, lowLimit: int, highLimit: int) -> int:
s1, s2 = str(lowLimit), str(highLimit)
diff --git "a/Solutions/1749. \344\273\273\346\204\217\345\255\220\346\225\260\347\273\204\345\222\214\347\232\204\347\273\235\345\257\271\345\200\274\347\232\204\346\234\200\345\244\247\345\200\274.md" "b/Solutions/1749. \344\273\273\346\204\217\345\255\220\346\225\260\347\273\204\345\222\214\347\232\204\347\273\235\345\257\271\345\200\274\347\232\204\346\234\200\345\244\247\345\200\274.md"
index 88be6c5f..3752bd37 100644
--- "a/Solutions/1749. \344\273\273\346\204\217\345\255\220\346\225\260\347\273\204\345\222\214\347\232\204\347\273\235\345\257\271\345\200\274\347\232\204\346\234\200\345\244\247\345\200\274.md"
+++ "b/Solutions/1749. \344\273\273\346\204\217\345\255\220\346\225\260\347\273\204\345\222\214\347\232\204\347\273\235\345\257\271\345\200\274\347\232\204\346\234\200\345\244\247\345\200\274.md"
@@ -23,7 +23,7 @@
- 示例 1:
-```Python
+```python
输入:nums = [1,-3,2,3,-4]
输出:5
解释:子数组 [2,3] 和的绝对值最大,为 abs(2+3) = abs(5) = 5。
@@ -31,7 +31,7 @@
- 示例 2:
-```Python
+```python
输入:nums = [2,-5,1,-4,3,-2]
输出:8
解释:子数组 [-5,1,-4] 和的绝对值最大,为 abs(-5+1-4) = abs(-8) = 8。
@@ -57,7 +57,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def maxAbsoluteSum(self, nums: List[int]) -> int:
ans = 0
diff --git "a/Solutions/1779. \346\211\276\345\210\260\346\234\200\350\277\221\347\232\204\346\234\211\347\233\270\345\220\214 X \346\210\226 Y \345\235\220\346\240\207\347\232\204\347\202\271.md" "b/Solutions/1779. \346\211\276\345\210\260\346\234\200\350\277\221\347\232\204\346\234\211\347\233\270\345\220\214 X \346\210\226 Y \345\235\220\346\240\207\347\232\204\347\202\271.md"
index fe6937ad..bc10c3cb 100644
--- "a/Solutions/1779. \346\211\276\345\210\260\346\234\200\350\277\221\347\232\204\346\234\211\347\233\270\345\220\214 X \346\210\226 Y \345\235\220\346\240\207\347\232\204\347\202\271.md"
+++ "b/Solutions/1779. \346\211\276\345\210\260\346\234\200\350\277\221\347\232\204\346\234\211\347\233\270\345\220\214 X \346\210\226 Y \345\235\220\346\240\207\347\232\204\347\202\271.md"
@@ -20,7 +20,7 @@
- 示例 1:
-```Python
+```python
输入:x = 3, y = 4, points = [[1, 2], [3, 1], [2, 4], [2, 3], [4, 4]]
输出:2
解释:在所有点中 [3, 1]、[2, 4]、[4, 4] 为有效点。其中 [2, 4]、[4, 4] 距离 [3, 4] 曼哈顿距离最近,都为 1。[2, 4] 下标最小,所以返回 2。
@@ -38,7 +38,7 @@
### 思路 1 代码:
-```Python
+```python
class Solution:
def nearestValidPoint(self, x: int, y: int, points: List[List[int]]) -> int:
min_dist = float('inf')
diff --git "a/Solutions/1790. \344\273\205\346\211\247\350\241\214\344\270\200\346\254\241\345\255\227\347\254\246\344\270\262\344\272\244\346\215\242\350\203\275\345\220\246\344\275\277\344\270\244\344\270\252\345\255\227\347\254\246\344\270\262\347\233\270\347\255\211.md" "b/Solutions/1790. \344\273\205\346\211\247\350\241\214\344\270\200\346\254\241\345\255\227\347\254\246\344\270\262\344\272\244\346\215\242\350\203\275\345\220\246\344\275\277\344\270\244\344\270\252\345\255\227\347\254\246\344\270\262\347\233\270\347\255\211.md"
index 27019591..06795403 100644
--- "a/Solutions/1790. \344\273\205\346\211\247\350\241\214\344\270\200\346\254\241\345\255\227\347\254\246\344\270\262\344\272\244\346\215\242\350\203\275\345\220\246\344\275\277\344\270\244\344\270\252\345\255\227\347\254\246\344\270\262\347\233\270\347\255\211.md"
+++ "b/Solutions/1790. \344\273\205\346\211\247\350\241\214\344\270\200\346\254\241\345\255\227\347\254\246\344\270\262\344\272\244\346\215\242\350\203\275\345\220\246\344\275\277\344\270\244\344\270\252\345\255\227\347\254\246\344\270\262\347\233\270\347\255\211.md"
@@ -21,7 +21,7 @@
- 示例 1:
-```Python
+```python
给定:s1 = "bank", s2 = "kanb"
输出:True
解释:交换 s1 中的第一个和最后一个字符可以得到 "kanb",与 s2 相同
@@ -44,7 +44,7 @@
### 思路 1 代码:
-```Python
+```python
class Solution:
def areAlmostEqual(self, s1: str, s2: str) -> bool:
size = len(s1)
diff --git "a/Solutions/1791. \346\211\276\345\207\272\346\230\237\345\236\213\345\233\276\347\232\204\344\270\255\345\277\203\350\212\202\347\202\271.md" "b/Solutions/1791. \346\211\276\345\207\272\346\230\237\345\236\213\345\233\276\347\232\204\344\270\255\345\277\203\350\212\202\347\202\271.md"
index 6ea6faec..1f94e7fc 100644
--- "a/Solutions/1791. \346\211\276\345\207\272\346\230\237\345\236\213\345\233\276\347\232\204\344\270\255\345\277\203\350\212\202\347\202\271.md"
+++ "b/Solutions/1791. \346\211\276\345\207\272\346\230\237\345\236\213\345\233\276\347\232\204\344\270\255\345\277\203\350\212\202\347\202\271.md"
@@ -26,7 +26,7 @@

-```Python
+```python
输入:edges = [[1,2],[2,3],[4,2]]
输出:2
解释:如上图所示,节点 2 与其他每个节点都相连,所以节点 2 是中心节点。
@@ -34,7 +34,7 @@
- 示例 2:
-```Python
+```python
输入:edges = [[1,2],[5,1],[1,3],[1,4]]
输出:1
```
@@ -47,7 +47,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def findCenter(self, edges: List[List[int]]) -> int:
n = len(edges) + 1
diff --git "a/Solutions/1822. \346\225\260\347\273\204\345\205\203\347\264\240\347\247\257\347\232\204\347\254\246\345\217\267.md" "b/Solutions/1822. \346\225\260\347\273\204\345\205\203\347\264\240\347\247\257\347\232\204\347\254\246\345\217\267.md"
index 3c4c0cf2..484978bd 100644
--- "a/Solutions/1822. \346\225\260\347\273\204\345\205\203\347\264\240\347\247\257\347\232\204\347\254\246\345\217\267.md"
+++ "b/Solutions/1822. \346\225\260\347\273\204\345\205\203\347\264\240\347\247\257\347\232\204\347\254\246\345\217\267.md"
@@ -24,7 +24,7 @@
- 示例 1:
-```Python
+```python
输入 nums = [-1,-2,-3,-4,3,2,1]
输出 1
解释 数组中所有值的乘积是 144,且 signFunc(144) = 1
@@ -48,7 +48,7 @@
### 思路 1 代码:
-```Python
+```python
class Solution:
def arraySign(self, nums: List[int]) -> int:
minus_count = 0
diff --git "a/Solutions/1833. \351\233\252\347\263\225\347\232\204\346\234\200\345\244\247\346\225\260\351\207\217.md" "b/Solutions/1833. \351\233\252\347\263\225\347\232\204\346\234\200\345\244\247\346\225\260\351\207\217.md"
index b890d8b5..d576def0 100644
--- "a/Solutions/1833. \351\233\252\347\263\225\347\232\204\346\234\200\345\244\247\346\225\260\351\207\217.md"
+++ "b/Solutions/1833. \351\233\252\347\263\225\347\232\204\346\234\200\345\244\247\346\225\260\351\207\217.md"
@@ -20,7 +20,7 @@
- 示例 1:
-```Python
+```python
输入:costs = [1,3,2,4,1], coins = 7
输出:4
解释:Tony 可以买下标为 0、1、2、4 的雪糕,总价为 1 + 3 + 2 + 1 = 7
@@ -28,7 +28,7 @@
- 示例 2:
-```Python
+```python
输入:costs = [10,6,8,7,7,8], coins = 5
输出:0
解释:Tony 没有足够的钱买任何一支雪糕。
@@ -46,7 +46,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def maxIceCream(self, costs: List[int], coins: int) -> int:
costs.sort()
diff --git "a/Solutions/1844. \345\260\206\346\211\200\346\234\211\346\225\260\345\255\227\347\224\250\345\255\227\347\254\246\346\233\277\346\215\242.md" "b/Solutions/1844. \345\260\206\346\211\200\346\234\211\346\225\260\345\255\227\347\224\250\345\255\227\347\254\246\346\233\277\346\215\242.md"
index 94afeb31..cadbdeb4 100644
--- "a/Solutions/1844. \345\260\206\346\211\200\346\234\211\346\225\260\345\255\227\347\224\250\345\255\227\347\254\246\346\233\277\346\215\242.md"
+++ "b/Solutions/1844. \345\260\206\346\211\200\346\234\211\346\225\260\345\255\227\347\224\250\345\255\227\347\254\246\346\233\277\346\215\242.md"
@@ -26,7 +26,7 @@
- 示例 1:
-```Python
+```python
输入:s = "a1c1e1"
输出:"abcdef"
解释:数字被替换结果如下:
@@ -37,7 +37,7 @@
- 示例 2:
-```Python
+```python
输入:s = "a1b2c3d4e"
输出:"abbdcfdhe"
解释:数字被替换结果如下:
@@ -58,7 +58,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def replaceDigits(self, s: str) -> str:
def shift(ch, x):
diff --git "a/Solutions/1858. \345\214\205\345\220\253\346\211\200\346\234\211\345\211\215\347\274\200\347\232\204\346\234\200\351\225\277\345\215\225\350\257\215.md" "b/Solutions/1858. \345\214\205\345\220\253\346\211\200\346\234\211\345\211\215\347\274\200\347\232\204\346\234\200\351\225\277\345\215\225\350\257\215.md"
index d04ac8cb..030a8df2 100644
--- "a/Solutions/1858. \345\214\205\345\220\253\346\211\200\346\234\211\345\211\215\347\274\200\347\232\204\346\234\200\351\225\277\345\215\225\350\257\215.md"
+++ "b/Solutions/1858. \345\214\205\345\220\253\346\211\200\346\234\211\345\211\215\347\274\200\347\232\204\346\234\200\351\225\277\345\215\225\350\257\215.md"
@@ -17,7 +17,7 @@
## 代码
-```Python
+```python
class Trie:
def __init__(self):
diff --git "a/Solutions/1859. \345\260\206\345\217\245\345\255\220\346\216\222\345\272\217.md" "b/Solutions/1859. \345\260\206\345\217\245\345\255\220\346\216\222\345\272\217.md"
index 054db6d3..b3f248c1 100644
--- "a/Solutions/1859. \345\260\206\345\217\245\345\255\220\346\216\222\345\272\217.md"
+++ "b/Solutions/1859. \345\260\206\345\217\245\345\255\220\346\216\222\345\272\217.md"
@@ -24,7 +24,7 @@
- 示例 1:
-```Python
+```python
输入:s = "is2 sentence4 This1 a3"
输出:"This is a sentence"
解释:将 s 中的单词按照初始位置排序,得到 "This1 is2 a3 sentence4" ,然后删除数字。
@@ -32,7 +32,7 @@
- 示例 2:
-```Python
+```python
输入:s = "Myself2 Me1 I4 and3"
输出:"Me Myself and I"
解释:将 s 中的单词按照初始位置排序,得到 "Me1 Myself2 and3 I4" ,然后删除数字。
@@ -50,7 +50,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def sortSentence(self, s: str) -> str:
s_list = s.split()
diff --git "a/Solutions/1876. \351\225\277\345\272\246\344\270\272\344\270\211\344\270\224\345\220\204\345\255\227\347\254\246\344\270\215\345\220\214\347\232\204\345\255\220\345\255\227\347\254\246\344\270\262.md" "b/Solutions/1876. \351\225\277\345\272\246\344\270\272\344\270\211\344\270\224\345\220\204\345\255\227\347\254\246\344\270\215\345\220\214\347\232\204\345\255\220\345\255\227\347\254\246\344\270\262.md"
index bdf74c79..fc6fe4a7 100644
--- "a/Solutions/1876. \351\225\277\345\272\246\344\270\272\344\270\211\344\270\224\345\220\204\345\255\227\347\254\246\344\270\215\345\220\214\347\232\204\345\255\220\345\255\227\347\254\246\344\270\262.md"
+++ "b/Solutions/1876. \351\225\277\345\272\246\344\270\272\344\270\211\344\270\224\345\220\204\345\255\227\347\254\246\344\270\215\345\220\214\347\232\204\345\255\220\345\255\227\347\254\246\344\270\262.md"
@@ -20,7 +20,7 @@
- 示例 1:
-```Python
+```python
输入:s = "xyzzaz"
输出:1
解释:总共有 4 个长度为 3 的子字符串:"xyz","yzz","zza" 和 "zaz" 。
@@ -29,7 +29,7 @@
- 示例 2:
-```Python
+```python
输入:s = "aababcabc"
输出:4
解释:总共有 7 个长度为 3 的子字符串:"aab","aba","bab","abc","bca","cab" 和 "abc" 。
@@ -46,7 +46,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def countGoodSubstrings(self, s: str) -> int:
ans = 0
diff --git "a/Solutions/1877. \346\225\260\347\273\204\344\270\255\346\234\200\345\244\247\346\225\260\345\257\271\345\222\214\347\232\204\346\234\200\345\260\217\345\200\274.md" "b/Solutions/1877. \346\225\260\347\273\204\344\270\255\346\234\200\345\244\247\346\225\260\345\257\271\345\222\214\347\232\204\346\234\200\345\260\217\345\200\274.md"
index c679339b..88eb0a77 100644
--- "a/Solutions/1877. \346\225\260\347\273\204\344\270\255\346\234\200\345\244\247\346\225\260\345\257\271\345\222\214\347\232\204\346\234\200\345\260\217\345\200\274.md"
+++ "b/Solutions/1877. \346\225\260\347\273\204\344\270\255\346\234\200\345\244\247\346\225\260\345\257\271\345\222\214\347\232\204\346\234\200\345\260\217\345\200\274.md"
@@ -27,7 +27,7 @@
- 示例 1:
-```Python
+```python
输入:nums = [3,5,2,3]
输出:7
解释:数组中的元素可以分为数对 (3,3) 和 (5,2)。
@@ -36,7 +36,7 @@
- 示例 2:
-```Python
+```python
输入:nums = [3,5,4,2,4,6]
输出:8
解释:数组中的元素可以分为数对 (3,5),(4,4) 和 (6,2)。
@@ -53,7 +53,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def minPairSum(self, nums: List[int]) -> int:
nums.sort()
diff --git "a/Solutions/1879. \344\270\244\344\270\252\346\225\260\347\273\204\346\234\200\345\260\217\347\232\204\345\274\202\346\210\226\345\200\274\344\271\213\345\222\214.md" "b/Solutions/1879. \344\270\244\344\270\252\346\225\260\347\273\204\346\234\200\345\260\217\347\232\204\345\274\202\346\210\226\345\200\274\344\271\213\345\222\214.md"
index fb4b6f2f..0980a38c 100644
--- "a/Solutions/1879. \344\270\244\344\270\252\346\225\260\347\273\204\346\234\200\345\260\217\347\232\204\345\274\202\346\210\226\345\200\274\344\271\213\345\222\214.md"
+++ "b/Solutions/1879. \344\270\244\344\270\252\346\225\260\347\273\204\346\234\200\345\260\217\347\232\204\345\274\202\346\210\226\345\200\274\344\271\213\345\222\214.md"
@@ -22,7 +22,7 @@
- 示例 1:
-```Python
+```python
输入:nums1 = [1,2], nums2 = [2,3]
输出:2
解释:将 nums2 重新排列得到 [3,2] 。
@@ -31,7 +31,7 @@
- 示例 2:
-```Python
+```python
输入:nums1 = [1,0,3], nums2 = [5,3,4]
输出:8
解释:将 nums2 重新排列得到 [5,4,3] 。
@@ -86,7 +86,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def minimumXORSum(self, nums1: List[int], nums2: List[int]) -> int:
ans = float('inf')
diff --git "a/Solutions/1903. \345\255\227\347\254\246\344\270\262\344\270\255\347\232\204\346\234\200\345\244\247\345\245\207\346\225\260.md" "b/Solutions/1903. \345\255\227\347\254\246\344\270\262\344\270\255\347\232\204\346\234\200\345\244\247\345\245\207\346\225\260.md"
index 66fd354c..102275ed 100644
--- "a/Solutions/1903. \345\255\227\347\254\246\344\270\262\344\270\255\347\232\204\346\234\200\345\244\247\345\245\207\346\225\260.md"
+++ "b/Solutions/1903. \345\255\227\347\254\246\344\270\262\344\270\255\347\232\204\346\234\200\345\244\247\345\245\207\346\225\260.md"
@@ -19,7 +19,7 @@
- 示例 1:
-```Python
+```python
输入:num = "52"
输出:"5"
解释:非空子字符串仅有 "5"、"2" 和 "52" 。"5" 是其中唯一的奇数。
@@ -27,7 +27,7 @@
- 示例 2:
-```Python
+```python
输入:num = "4206"
输出:""
解释:在 "4206" 中不存在奇数。
@@ -44,7 +44,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def largestOddNumber(self, num: str) -> str:
for i in range(len(num) - 1, -1, -1):
diff --git "a/Solutions/1925. \347\273\237\350\256\241\345\271\263\346\226\271\345\222\214\344\270\211\345\205\203\347\273\204\347\232\204\346\225\260\347\233\256.md" "b/Solutions/1925. \347\273\237\350\256\241\345\271\263\346\226\271\345\222\214\344\270\211\345\205\203\347\273\204\347\232\204\346\225\260\347\233\256.md"
index e64d1598..191ea162 100644
--- "a/Solutions/1925. \347\273\237\350\256\241\345\271\263\346\226\271\345\222\214\344\270\211\345\205\203\347\273\204\347\232\204\346\225\260\347\233\256.md"
+++ "b/Solutions/1925. \347\273\237\350\256\241\345\271\263\346\226\271\345\222\214\344\270\211\345\205\203\347\273\204\347\232\204\346\225\260\347\233\256.md"
@@ -18,7 +18,7 @@
- 示例 1:
-```Python
+```python
输入 n = 5
输出 2
解释 平方和三元组为 (3,4,5) 和 (4,3,5)。
@@ -26,7 +26,7 @@
- 示例 2:
-```Python
+```python
输入:n = 10
输出:4
解释:平方和三元组为 (3,4,5),(4,3,5),(6,8,10) 和 (8,6,10)。
@@ -46,7 +46,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def countTriples(self, n: int) -> int:
cnt = 0
diff --git "a/Solutions/1929. \346\225\260\347\273\204\344\270\262\350\201\224.md" "b/Solutions/1929. \346\225\260\347\273\204\344\270\262\350\201\224.md"
index 0ae5e70b..7b1a1a6b 100644
--- "a/Solutions/1929. \346\225\260\347\273\204\344\270\262\350\201\224.md"
+++ "b/Solutions/1929. \346\225\260\347\273\204\344\270\262\350\201\224.md"
@@ -24,7 +24,7 @@
- 示例 1:
-```Python
+```python
输入:nums = [1,2,1]
输出:[1,2,1,1,2,1]
解释:数组 ans 按下述方式形成:
@@ -34,7 +34,7 @@
- 示例 2:
-```Python
+```python
输入:nums = [1,3,2,1]
输出:[1,3,2,1,1,3,2,1]
解释:数组 ans 按下述方式形成:
@@ -51,7 +51,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def getConcatenation(self, nums: List[int]) -> List[int]:
ans = []
@@ -73,7 +73,7 @@ class Solution:
### 思路 2:代码
-```Python
+```python
class Solution:
def getConcatenation(self, nums: List[int]) -> List[int]:
return nums + nums
diff --git "a/Solutions/1941. \346\243\200\346\237\245\346\230\257\345\220\246\346\211\200\346\234\211\345\255\227\347\254\246\345\207\272\347\216\260\346\254\241\346\225\260\347\233\270\345\220\214.md" "b/Solutions/1941. \346\243\200\346\237\245\346\230\257\345\220\246\346\211\200\346\234\211\345\255\227\347\254\246\345\207\272\347\216\260\346\254\241\346\225\260\347\233\270\345\220\214.md"
index 64af0ae6..aec00e21 100644
--- "a/Solutions/1941. \346\243\200\346\237\245\346\230\257\345\220\246\346\211\200\346\234\211\345\255\227\347\254\246\345\207\272\347\216\260\346\254\241\346\225\260\347\233\270\345\220\214.md"
+++ "b/Solutions/1941. \346\243\200\346\237\245\346\230\257\345\220\246\346\211\200\346\234\211\345\255\227\347\254\246\345\207\272\347\216\260\346\254\241\346\225\260\347\233\270\345\220\214.md"
@@ -18,7 +18,7 @@
- 示例 1:
-```Python
+```python
输入:s = "abacbc"
输出:true
解释:s 中出现过的字符为 'a','b' 和 'c' 。s 中所有字符均出现 2 次。
@@ -26,7 +26,7 @@
- 示例 2:
-```Python
+```python
输入:s = "aaabb"
输出:false
解释:s 中出现过的字符为 'a' 和 'b' 。
@@ -44,7 +44,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def areOccurrencesEqual(self, s: str) -> bool:
counter = Counter(s)
diff --git "a/Solutions/1947. \346\234\200\345\244\247\345\205\274\345\256\271\346\200\247\350\257\204\345\210\206\345\222\214.md" "b/Solutions/1947. \346\234\200\345\244\247\345\205\274\345\256\271\346\200\247\350\257\204\345\210\206\345\222\214.md"
index e3c27076..c52d5166 100644
--- "a/Solutions/1947. \346\234\200\345\244\247\345\205\274\345\256\271\346\200\247\350\257\204\345\210\206\345\222\214.md"
+++ "b/Solutions/1947. \346\234\200\345\244\247\345\205\274\345\256\271\346\200\247\350\257\204\345\210\206\345\222\214.md"
@@ -25,7 +25,7 @@
- 示例 1:
-```Python
+```python
输入:students = [[1,1,0],[1,0,1],[0,0,1]], mentors = [[1,0,0],[0,0,1],[1,1,0]]
输出:8
解释:按下述方式分配学生和导师:
@@ -37,7 +37,7 @@
- 示例 2:
-```Python
+```python
输入:students = [[0,0],[0,0],[0,0]], mentors = [[1,1],[1,1],[1,1]]
输出:0
解释:任意学生与导师配对的兼容性评分都是 0。
@@ -83,7 +83,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def maxCompatibilitySum(self, students: List[List[int]], mentors: List[List[int]]) -> int:
m, n = len(students), len(students[0])
diff --git "a/Solutions/1986. \345\256\214\346\210\220\344\273\273\345\212\241\347\232\204\346\234\200\345\260\221\345\267\245\344\275\234\346\227\266\351\227\264\346\256\265.md" "b/Solutions/1986. \345\256\214\346\210\220\344\273\273\345\212\241\347\232\204\346\234\200\345\260\221\345\267\245\344\275\234\346\227\266\351\227\264\346\256\265.md"
index 17e1c89b..51986908 100644
--- "a/Solutions/1986. \345\256\214\346\210\220\344\273\273\345\212\241\347\232\204\346\234\200\345\260\221\345\267\245\344\275\234\346\227\266\351\227\264\346\256\265.md"
+++ "b/Solutions/1986. \345\256\214\346\210\220\344\273\273\345\212\241\347\232\204\346\234\200\345\260\221\345\267\245\344\275\234\346\227\266\351\227\264\346\256\265.md"
@@ -26,7 +26,7 @@
- 示例 1:
-```Python
+```python
输入:tasks = [1,2,3], sessionTime = 3
输出:2
解释:你可以在两个工作时间段内完成所有任务。
@@ -36,7 +36,7 @@
- 示例 2:
-```Python
+```python
输入:tasks = [3,1,3,1,1], sessionTime = 8
输出:2
解释:你可以在两个工作时间段内完成所有任务。
@@ -50,7 +50,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def minSessions(self, tasks: List[int], sessionTime: int) -> int:
size = len(tasks)
diff --git "a/Solutions/1991. \346\211\276\345\210\260\346\225\260\347\273\204\347\232\204\344\270\255\351\227\264\344\275\215\347\275\256.md" "b/Solutions/1991. \346\211\276\345\210\260\346\225\260\347\273\204\347\232\204\344\270\255\351\227\264\344\275\215\347\275\256.md"
index d549dd54..3ed0d2fa 100644
--- "a/Solutions/1991. \346\211\276\345\210\260\346\225\260\347\273\204\347\232\204\344\270\255\351\227\264\344\275\215\347\275\256.md"
+++ "b/Solutions/1991. \346\211\276\345\210\260\346\225\260\347\273\204\347\232\204\344\270\255\351\227\264\344\275\215\347\275\256.md"
@@ -18,7 +18,7 @@
- 示例 1:
-```Python
+```python
输入:nums = [2,3,-1,8,4]
输出:3
解释:
@@ -28,7 +28,7 @@
- 示例 2:
-```Python
+```python
输入:nums = [1,-1,4]
输出:2
解释:
@@ -49,7 +49,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def findMiddleIndex(self, nums: List[int]) -> int:
total = sum(nums)
diff --git "a/Solutions/1994. \345\245\275\345\255\220\351\233\206\347\232\204\346\225\260\347\233\256.md" "b/Solutions/1994. \345\245\275\345\255\220\351\233\206\347\232\204\346\225\260\347\233\256.md"
index 5dbcb5ef..8027558d 100644
--- "a/Solutions/1994. \345\245\275\345\255\220\351\233\206\347\232\204\346\225\260\347\233\256.md"
+++ "b/Solutions/1994. \345\245\275\345\255\220\351\233\206\347\232\204\346\225\260\347\233\256.md"
@@ -25,7 +25,7 @@
- 示例 1:
-```Python
+```python
输入:nums = [1,2,3,4]
输出:6
解释:好子集为:
@@ -39,7 +39,7 @@
- 示例 2:
-```Python
+```python
输入:nums = [4,2,3,15]
输出:5
解释:好子集为:
@@ -89,7 +89,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def numberOfGoodSubsets(self, nums: List[int]) -> int:
MOD = 10 ** 9 + 7
diff --git "a/Solutions/2011. \346\211\247\350\241\214\346\223\215\344\275\234\345\220\216\347\232\204\345\217\230\351\207\217\345\200\274.md" "b/Solutions/2011. \346\211\247\350\241\214\346\223\215\344\275\234\345\220\216\347\232\204\345\217\230\351\207\217\345\200\274.md"
index 0fc309ee..2a422a8f 100644
--- "a/Solutions/2011. \346\211\247\350\241\214\346\223\215\344\275\234\345\220\216\347\232\204\345\217\230\351\207\217\345\200\274.md"
+++ "b/Solutions/2011. \346\211\247\350\241\214\346\223\215\344\275\234\345\220\216\347\232\204\345\217\230\351\207\217\345\200\274.md"
@@ -22,7 +22,7 @@
## 代码
-```Python
+```python
def finalValueAfterOperations(self, operations):
"""
:type operations: List[str]
diff --git "a/Solutions/2023. \350\277\236\346\216\245\345\220\216\347\255\211\344\272\216\347\233\256\346\240\207\345\255\227\347\254\246\344\270\262\347\232\204\345\255\227\347\254\246\344\270\262\345\257\271.md" "b/Solutions/2023. \350\277\236\346\216\245\345\220\216\347\255\211\344\272\216\347\233\256\346\240\207\345\255\227\347\254\246\344\270\262\347\232\204\345\255\227\347\254\246\344\270\262\345\257\271.md"
index d97aff07..55a1bd1e 100644
--- "a/Solutions/2023. \350\277\236\346\216\245\345\220\216\347\255\211\344\272\216\347\233\256\346\240\207\345\255\227\347\254\246\344\270\262\347\232\204\345\255\227\347\254\246\344\270\262\345\257\271.md"
+++ "b/Solutions/2023. \350\277\236\346\216\245\345\220\216\347\255\211\344\272\216\347\233\256\346\240\207\345\255\227\347\254\246\344\270\262\347\232\204\345\255\227\347\254\246\344\270\262\345\257\271.md"
@@ -21,7 +21,7 @@
- 示例 1:
-```Python
+```python
输入:nums = ["777","7","77","77"], target = "7777"
输出:4
解释:符合要求的下标对包括:
@@ -33,7 +33,7 @@
- 示例 2:
-```Python
+```python
输入:nums = ["123","4","12","34"], target = "1234"
输出:2
解释:符合要求的下标对包括
@@ -50,7 +50,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def numOfPairs(self, nums: List[str], target: str) -> int:
res = 0
@@ -79,7 +79,7 @@ class Solution:
### 思路 2:代码
-```Python
+```python
class Solution:
def numOfPairs(self, nums: List[str], target: str) -> int:
res = 0
diff --git "a/Solutions/2050. \345\271\266\350\241\214\350\257\276\347\250\213 III.md" "b/Solutions/2050. \345\271\266\350\241\214\350\257\276\347\250\213 III.md"
index 4a8f9440..7a595260 100644
--- "a/Solutions/2050. \345\271\266\350\241\214\350\257\276\347\250\213 III.md"
+++ "b/Solutions/2050. \345\271\266\350\241\214\350\257\276\347\250\213 III.md"
@@ -36,7 +36,7 @@

-```Python
+```python
输入:n = 3, relations = [[1,3],[2,3]], time = [3,2,5]
输出:8
解释:上图展示了输入数据所表示的先修关系图,以及完成每门课程需要花费的时间。
@@ -49,7 +49,7 @@

-```Python
+```python
输入:n = 5, relations = [[1,5],[2,5],[3,5],[3,4],[4,5]], time = [1,2,3,4,5]
输出:12
解释:上图展示了输入数据所表示的先修关系图,以及完成每门课程需要花费的时间。
@@ -75,7 +75,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def minimumTime(self, n: int, relations: List[List[int]], time: List[int]) -> int:
graph = [[] for _ in range(n + 1)]
diff --git "a/Solutions/2156. \346\237\245\346\211\276\347\273\231\345\256\232\345\223\210\345\270\214\345\200\274\347\232\204\345\255\220\344\270\262.md" "b/Solutions/2156. \346\237\245\346\211\276\347\273\231\345\256\232\345\223\210\345\270\214\345\200\274\347\232\204\345\255\220\344\270\262.md"
index 339f54f7..816cb5f5 100644
--- "a/Solutions/2156. \346\237\245\346\211\276\347\273\231\345\256\232\345\223\210\345\270\214\345\200\274\347\232\204\345\255\220\344\270\262.md"
+++ "b/Solutions/2156. \346\237\245\346\211\276\347\273\231\345\256\232\345\223\210\345\270\214\345\200\274\347\232\204\345\255\220\344\270\262.md"
@@ -28,7 +28,7 @@
- 示例 1:
-```Python
+```python
输入:s = "leetcode", power = 7, modulo = 20, k = 2, hashValue = 0
输出:"ee"
解释:"ee" 的哈希值为 hash("ee", 7, 20) = (5 * 1 + 5 * 7) mod 20 = 40 mod 20 = 0 。
@@ -74,7 +74,7 @@ $\begin{align} Hash(s_{[i - 1, i + k - 2]}) &= \{[Hash(s_{[i, i + k - 1]}) - s_
### 思路 1:代码
-```Python
+```python
class Solution:
def subStrHash(self, s: str, power: int, modulo: int, k: int, hashValue: int) -> str:
hash_t = 0
diff --git "a/Solutions/2172. \346\225\260\347\273\204\347\232\204\346\234\200\345\244\247\344\270\216\345\222\214.md" "b/Solutions/2172. \346\225\260\347\273\204\347\232\204\346\234\200\345\244\247\344\270\216\345\222\214.md"
index 1c5ae283..8e5c3b38 100644
--- "a/Solutions/2172. \346\225\260\347\273\204\347\232\204\346\234\200\345\244\247\344\270\216\345\222\214.md"
+++ "b/Solutions/2172. \346\225\260\347\273\204\347\232\204\346\234\200\345\244\247\344\270\216\345\222\214.md"
@@ -24,7 +24,7 @@
- 示例 1:
-```Python
+```python
输入:nums = [1,2,3,4,5,6], numSlots = 3
输出:9
解释:一个可行的方案是 [1, 4] 放入篮子 1 中,[2, 6] 放入篮子 2 中,[3, 5] 放入篮子 3 中。
@@ -33,7 +33,7 @@
- 示例 2:
-```Python
+```python
输入:nums = [1,3,10,4,7,1], numSlots = 9
输出:24
解释:一个可行的方案是 [1, 1] 放入篮子 1 中,[3] 放入篮子 3 中,[4] 放入篮子 4 中,[7] 放入篮子 7 中,[10] 放入篮子 9 中。
@@ -86,7 +86,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def maximumANDSum(self, nums: List[int], numSlots: int) -> int:
states = 1 << (numSlots * 2)
diff --git "a/Solutions/2235. \344\270\244\346\225\264\346\225\260\347\233\270\345\212\240.md" "b/Solutions/2235. \344\270\244\346\225\264\346\225\260\347\233\270\345\212\240.md"
index f79b3fd6..d43e191a 100644
--- "a/Solutions/2235. \344\270\244\346\225\264\346\225\260\347\233\270\345\212\240.md"
+++ "b/Solutions/2235. \344\270\244\346\225\264\346\225\260\347\233\270\345\212\240.md"
@@ -17,7 +17,7 @@
- 示例 1:
-```Python
+```python
示例 1:
输入:num1 = 12, num2 = 5
输出:17
@@ -26,7 +26,7 @@
- 示例 2:
-```Python
+```python
输入:num1 = -10, num2 = 4
输出:-6
解释:num1 + num2 = -6,因此返回 -6。
@@ -40,7 +40,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def sum(self, num1: int, num2: int) -> int:
return num1 + num2
diff --git "a/Solutions/2246. \347\233\270\351\202\273\345\255\227\347\254\246\344\270\215\345\220\214\347\232\204\346\234\200\351\225\277\350\267\257\345\276\204.md" "b/Solutions/2246. \347\233\270\351\202\273\345\255\227\347\254\246\344\270\215\345\220\214\347\232\204\346\234\200\351\225\277\350\267\257\345\276\204.md"
index a7aa4ab6..d85f43b6 100644
--- "a/Solutions/2246. \347\233\270\351\202\273\345\255\227\347\254\246\344\270\215\345\220\214\347\232\204\346\234\200\351\225\277\350\267\257\345\276\204.md"
+++ "b/Solutions/2246. \347\233\270\351\202\273\345\255\227\347\254\246\344\270\215\345\220\214\347\232\204\346\234\200\351\225\277\350\267\257\345\276\204.md"
@@ -24,7 +24,7 @@

-```Python
+```python
输入:parent = [-1,0,0,1,1,2], s = "abacbe"
输出:3
解释:任意一对相邻节点字符都不同的最长路径是:0 -> 1 -> 3 。该路径的长度是 3 ,所以返回 3。
@@ -35,7 +35,7 @@

-```Python
+```python
输入:parent = [-1,0,0,0], s = "aabc"
输出:3
解释:任意一对相邻节点字符都不同的最长路径是:2 -> 0 -> 3 。该路径的长度为 3 ,所以返回 3。
@@ -68,7 +68,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def longestPath(self, parent: List[int], s: str) -> int:
size = len(parent)
diff --git "a/Solutions/2249. \347\273\237\350\256\241\345\234\206\345\206\205\346\240\274\347\202\271\346\225\260\347\233\256.md" "b/Solutions/2249. \347\273\237\350\256\241\345\234\206\345\206\205\346\240\274\347\202\271\346\225\260\347\233\256.md"
index 932d76dd..451d2cd3 100644
--- "a/Solutions/2249. \347\273\237\350\256\241\345\234\206\345\206\205\346\240\274\347\202\271\346\225\260\347\233\256.md"
+++ "b/Solutions/2249. \347\273\237\350\256\241\345\234\206\345\206\205\346\240\274\347\202\271\346\225\260\347\233\256.md"
@@ -24,7 +24,7 @@

-```Python
+```python
输入:circles = [[2,2,1]]
输出:5
解释:
@@ -36,7 +36,7 @@
- 示例 2:
-```Python
+```python
输入:circles = [[2,2,2],[3,4,1]]
输出:16
解释:
@@ -57,7 +57,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def countLatticePoints(self, circles: List[List[int]]) -> int:
min_x, min_y = 200, 200
diff --git "a/Solutions/2276. \347\273\237\350\256\241\345\214\272\351\227\264\344\270\255\347\232\204\346\225\264\346\225\260\346\225\260\347\233\256.md" "b/Solutions/2276. \347\273\237\350\256\241\345\214\272\351\227\264\344\270\255\347\232\204\346\225\264\346\225\260\346\225\260\347\233\256.md"
index 804e61d3..d36ebe20 100644
--- "a/Solutions/2276. \347\273\237\350\256\241\345\214\272\351\227\264\344\270\255\347\232\204\346\225\264\346\225\260\346\225\260\347\233\256.md"
+++ "b/Solutions/2276. \347\273\237\350\256\241\345\214\272\351\227\264\344\270\255\347\232\204\346\225\264\346\225\260\346\225\260\347\233\256.md"
@@ -29,7 +29,7 @@
- 示例 1:
-```Python
+```python
输入:
["CountIntervals", "add", "add", "count", "add", "count"]
[[], [2, 3], [7, 10], [], [5, 8], []]
@@ -67,7 +67,7 @@ countIntervals.count(); // 返回 8
### 思路 1:动态开点线段树代码
-```Python
+```python
# 线段树的节点类
class SegTreeNode:
def __init__(self, left=-1, right=-1, val=0, lazy_tag=None, leftNode=None, rightNode=None):
diff --git "a/Solutions/2376. \347\273\237\350\256\241\347\211\271\346\256\212\346\225\264\346\225\260.md" "b/Solutions/2376. \347\273\237\350\256\241\347\211\271\346\256\212\346\225\264\346\225\260.md"
index f9ff4a55..3ab07d52 100644
--- "a/Solutions/2376. \347\273\237\350\256\241\347\211\271\346\256\212\346\225\264\346\225\260.md"
+++ "b/Solutions/2376. \347\273\237\350\256\241\347\211\271\346\256\212\346\225\264\346\225\260.md"
@@ -18,7 +18,7 @@
- 示例 1:
-```Python
+```python
输入:n = 20
输出:19
解释:1 到 20 之间所有整数除了 11 以外都是特殊整数。所以总共有 19 个特殊整数。
@@ -26,7 +26,7 @@
- 示例 2:
-```Python
+```python
输入:n = 5
输出:5
解释:1 到 5 所有整数都是特殊整数。
@@ -62,7 +62,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def countSpecialNumbers(self, n: int) -> int:
# 将 n 转换为字符串 s
diff --git "a/Solutions/2427. \345\205\254\345\233\240\345\255\220\347\232\204\346\225\260\347\233\256.md" "b/Solutions/2427. \345\205\254\345\233\240\345\255\220\347\232\204\346\225\260\347\233\256.md"
index 9b083854..4f326fea 100644
--- "a/Solutions/2427. \345\205\254\345\233\240\345\255\220\347\232\204\346\225\260\347\233\256.md"
+++ "b/Solutions/2427. \345\205\254\345\233\240\345\255\220\347\232\204\346\225\260\347\233\256.md"
@@ -18,7 +18,7 @@
- 示例 1:
-```Python
+```python
输入:a = 12, b = 6
输出:4
解释:12 和 6 的公因子是 1、2、3、6。
@@ -26,7 +26,7 @@
- 示例 2:
-```Python
+```python
输入:a = 25, b = 30
输出:2
解释:25 和 30 的公因子是 1、5。
@@ -42,7 +42,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def commonFactors(self, a: int, b: int) -> int:
ans = 0
diff --git "a/Solutions/2538. \346\234\200\345\244\247\344\273\267\345\200\274\345\222\214\344\270\216\346\234\200\345\260\217\344\273\267\345\200\274\345\222\214\347\232\204\345\267\256\345\200\274.md" "b/Solutions/2538. \346\234\200\345\244\247\344\273\267\345\200\274\345\222\214\344\270\216\346\234\200\345\260\217\344\273\267\345\200\274\345\222\214\347\232\204\345\267\256\345\200\274.md"
index 6ca0398f..1f7a6b6e 100644
--- "a/Solutions/2538. \346\234\200\345\244\247\344\273\267\345\200\274\345\222\214\344\270\216\346\234\200\345\260\217\344\273\267\345\200\274\345\222\214\347\232\204\345\267\256\345\200\274.md"
+++ "b/Solutions/2538. \346\234\200\345\244\247\344\273\267\345\200\274\345\222\214\344\270\216\346\234\200\345\260\217\344\273\267\345\200\274\345\222\214\347\232\204\345\267\256\345\200\274.md"
@@ -28,7 +28,7 @@

-```Python
+```python
输入:n = 6, edges = [[0,1],[1,2],[1,3],[3,4],[3,5]], price = [9,8,7,6,10,5]
输出:24
解释:上图展示了以节点 2 为根的树。左图(红色的节点)是最大价值和路径,右图(蓝色的节点)是最小价值和路径。
@@ -41,7 +41,7 @@

-```Python
+```python
输入:n = 3, edges = [[0,1],[1,2]], price = [1,1,1]
输出:2
解释:上图展示了以节点 0 为根的树。左图(红色的节点)是最大价值和路径,右图(蓝色的节点)是最小价值和路径。
@@ -83,7 +83,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def __init__(self):
self.ans = 0
diff --git "a/Solutions/2585. \350\216\267\345\276\227\345\210\206\346\225\260\347\232\204\346\226\271\346\263\225\346\225\260.md" "b/Solutions/2585. \350\216\267\345\276\227\345\210\206\346\225\260\347\232\204\346\226\271\346\263\225\346\225\260.md"
index da8af8f5..168faf91 100644
--- "a/Solutions/2585. \350\216\267\345\276\227\345\210\206\346\225\260\347\232\204\346\226\271\346\263\225\346\225\260.md"
+++ "b/Solutions/2585. \350\216\267\345\276\227\345\210\206\346\225\260\347\232\204\346\226\271\346\263\225\346\225\260.md"
@@ -22,7 +22,7 @@
- 示例 1:
-```Python
+```python
输入:target = 6, types = [[6,1],[3,2],[2,3]]
输出:7
解释:要获得 6 分,你可以选择以下七种方法之一:
@@ -37,7 +37,7 @@
- 示例 2:
-```Python
+```python
输入:target = 5, types = [[50,1],[50,2],[50,5]]
输出:4
解释:要获得 5 分,你可以选择以下四种方法之一:
@@ -73,7 +73,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def waysToReachTarget(self, target: int, types: List[List[int]]) -> int:
size = len(types)
diff --git "a/Solutions/2719. \347\273\237\350\256\241\346\225\264\346\225\260\346\225\260\347\233\256.md" "b/Solutions/2719. \347\273\237\350\256\241\346\225\264\346\225\260\346\225\260\347\233\256.md"
index 6e66269c..39335ec9 100644
--- "a/Solutions/2719. \347\273\237\350\256\241\346\225\264\346\225\260\346\225\260\347\233\256.md"
+++ "b/Solutions/2719. \347\273\237\350\256\241\346\225\264\346\225\260\346\225\260\347\233\256.md"
@@ -23,7 +23,7 @@
- 示例 1:
-```Python
+```python
输入:num1 = "1", num2 = "12", min_num = 1, max_num = 8
输出:11
解释:总共有 11 个整数的数位和在 1 到 8 之间,分别是 1,2,3,4,5,6,7,8,10,11 和 12 。所以我们返回 11。
@@ -31,7 +31,7 @@
- 示例 2:
-```Python
+```python
输入:num1 = "1", num2 = "5", min_num = 1, max_num = 5
输出:5
解释:数位和在 1 到 5 之间的 5 个整数分别为 1,2,3,4 和 5 。所以我们返回 5。
@@ -63,7 +63,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def count(self, num1: str, num2: str, min_sum: int, max_sum: int) -> int:
MOD = 10 ** 9 + 7
diff --git "a/Solutions/LeetCode \350\247\243\351\242\230\346\212\245\345\221\212\347\251\272\347\231\275 (\345\212\250\346\200\201\350\247\204\345\210\222).md" "b/Solutions/LeetCode \350\247\243\351\242\230\346\212\245\345\221\212\347\251\272\347\231\275 (\345\212\250\346\200\201\350\247\204\345\210\222).md"
index 5aa9da83..f4a9e49a 100644
--- "a/Solutions/LeetCode \350\247\243\351\242\230\346\212\245\345\221\212\347\251\272\347\231\275 (\345\212\250\346\200\201\350\247\204\345\210\222).md"
+++ "b/Solutions/LeetCode \350\247\243\351\242\230\346\212\245\345\221\212\347\251\272\347\231\275 (\345\212\250\346\200\201\350\247\204\345\210\222).md"
@@ -17,12 +17,12 @@
- 示例 1:
-```Python
+```python
```
- 示例 2:
-```Python
+```python
```
## 解题思路
@@ -51,7 +51,7 @@
### 思路 1:代码
-```Python
+```python
```
diff --git "a/Solutions/LeetCode \350\247\243\351\242\230\346\212\245\345\221\212\347\251\272\347\231\275.md" "b/Solutions/LeetCode \350\247\243\351\242\230\346\212\245\345\221\212\347\251\272\347\231\275.md"
index 08b6597f..1e1c8ef3 100644
--- "a/Solutions/LeetCode \350\247\243\351\242\230\346\212\245\345\221\212\347\251\272\347\231\275.md"
+++ "b/Solutions/LeetCode \350\247\243\351\242\230\346\212\245\345\221\212\347\251\272\347\231\275.md"
@@ -17,12 +17,12 @@
- 示例 1:
-```Python
+```python
```
- 示例 2:
-```Python
+```python
```
## 解题思路
@@ -33,7 +33,7 @@
### 思路 1:代码
-```Python
+```python
```
@@ -48,7 +48,7 @@
### 思路 2:代码
-```Python
+```python
```
diff --git "a/Solutions/\345\211\221\346\214\207 Offer 03. \346\225\260\347\273\204\344\270\255\351\207\215\345\244\215\347\232\204\346\225\260\345\255\227.md" "b/Solutions/\345\211\221\346\214\207 Offer 03. \346\225\260\347\273\204\344\270\255\351\207\215\345\244\215\347\232\204\346\225\260\345\255\227.md"
index b376e599..1bb00223 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer 03. \346\225\260\347\273\204\344\270\255\351\207\215\345\244\215\347\232\204\346\225\260\345\255\227.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer 03. \346\225\260\347\273\204\344\270\255\351\207\215\345\244\215\347\232\204\346\225\260\345\255\227.md"
@@ -13,7 +13,7 @@
## 代码
-```Python
+```python
class Solution:
def findRepeatNumber(self, nums: List[int]) -> int:
nums_dict = dict()
diff --git "a/Solutions/\345\211\221\346\214\207 Offer 04. \344\272\214\347\273\264\346\225\260\347\273\204\344\270\255\347\232\204\346\237\245\346\211\276.md" "b/Solutions/\345\211\221\346\214\207 Offer 04. \344\272\214\347\273\264\346\225\260\347\273\204\344\270\255\347\232\204\346\237\245\346\211\276.md"
index 366d12d9..06439d9d 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer 04. \344\272\214\347\273\264\346\225\260\347\273\204\344\270\255\347\232\204\346\237\245\346\211\276.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer 04. \344\272\214\347\273\264\346\225\260\347\273\204\344\270\255\347\232\204\346\237\245\346\211\276.md"
@@ -23,7 +23,7 @@
## 代码
-```Python
+```python
class Solution:
def diagonalBinarySearch(self, matrix, diagonal, target):
left = 0
diff --git "a/Solutions/\345\211\221\346\214\207 Offer 05. \346\233\277\346\215\242\347\251\272\346\240\274.md" "b/Solutions/\345\211\221\346\214\207 Offer 05. \346\233\277\346\215\242\347\251\272\346\240\274.md"
index 1668015f..ad5bbd15 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer 05. \346\233\277\346\215\242\347\251\272\346\240\274.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer 05. \346\233\277\346\215\242\347\251\272\346\240\274.md"
@@ -20,7 +20,7 @@ Python 的字符串是不可变类型,所以需要先用数组存储答案,
## 代码
-```Python
+```python
class Solution:
def replaceSpace(self, s: str) -> str:
res = []
diff --git "a/Solutions/\345\211\221\346\214\207 Offer 06. \344\273\216\345\260\276\345\210\260\345\244\264\346\211\223\345\215\260\351\223\276\350\241\250.md" "b/Solutions/\345\211\221\346\214\207 Offer 06. \344\273\216\345\260\276\345\210\260\345\244\264\346\211\223\345\215\260\351\223\276\350\241\250.md"
index a82fe093..4bee5afe 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer 06. \344\273\216\345\260\276\345\210\260\345\244\264\346\211\223\345\215\260\351\223\276\350\241\250.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer 06. \344\273\216\345\260\276\345\210\260\345\244\264\346\211\223\345\215\260\351\223\276\350\241\250.md"
@@ -17,7 +17,7 @@
## 代码
-```Python
+```python
class Solution:
def reversePrint(self, head: ListNode) -> List[int]:
res = []
diff --git "a/Solutions/\345\211\221\346\214\207 Offer 07. \351\207\215\345\273\272\344\272\214\345\217\211\346\240\221.md" "b/Solutions/\345\211\221\346\214\207 Offer 07. \351\207\215\345\273\272\344\272\214\345\217\211\346\240\221.md"
index 8a288a03..5305e4d0 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer 07. \351\207\215\345\273\272\344\272\214\345\217\211\346\240\221.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer 07. \351\207\215\345\273\272\344\272\214\345\217\211\346\240\221.md"
@@ -20,7 +20,7 @@
## 代码
-```Python
+```python
class Solution:
def buildTree(self, preorder: List[int], inorder: List[int]) -> TreeNode:
def createTree(preorder, inorder, n):
diff --git "a/Solutions/\345\211\221\346\214\207 Offer 09. \347\224\250\344\270\244\344\270\252\346\240\210\345\256\236\347\216\260\351\230\237\345\210\227.md" "b/Solutions/\345\211\221\346\214\207 Offer 09. \347\224\250\344\270\244\344\270\252\346\240\210\345\256\236\347\216\260\351\230\237\345\210\227.md"
index 543d1232..704fda3c 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer 09. \347\224\250\344\270\244\344\270\252\346\240\210\345\256\236\347\216\260\351\230\237\345\210\227.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer 09. \347\224\250\344\270\244\344\270\252\346\240\210\345\256\236\347\216\260\351\230\237\345\210\227.md"
@@ -21,7 +21,7 @@
## 代码
-```Python
+```python
class CQueue:
def __init__(self):
diff --git "a/Solutions/\345\211\221\346\214\207 Offer 10- I. \346\226\220\346\263\242\351\202\243\345\245\221\346\225\260\345\210\227.md" "b/Solutions/\345\211\221\346\214\207 Offer 10- I. \346\226\220\346\263\242\351\202\243\345\245\221\346\225\260\345\210\227.md"
index 1b5961c6..8cc7a2c2 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer 10- I. \346\226\220\346\263\242\351\202\243\345\245\221\346\225\260\345\210\227.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer 10- I. \346\226\220\346\263\242\351\202\243\345\245\221\346\225\260\345\210\227.md"
@@ -19,7 +19,7 @@
## 代码
-```Python
+```python
class Solution:
def fib(self, n: int) -> int:
if n < 2:
diff --git "a/Solutions/\345\211\221\346\214\207 Offer 10- II. \351\235\222\350\233\231\350\267\263\345\217\260\351\230\266\351\227\256\351\242\230.md" "b/Solutions/\345\211\221\346\214\207 Offer 10- II. \351\235\222\350\233\231\350\267\263\345\217\260\351\230\266\351\227\256\351\242\230.md"
index 872d652a..45ef67ad 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer 10- II. \351\235\222\350\233\231\350\267\263\345\217\260\351\230\266\351\227\256\351\242\230.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer 10- II. \351\235\222\350\233\231\350\267\263\345\217\260\351\230\266\351\227\256\351\242\230.md"
@@ -28,7 +28,7 @@
## 代码
-```Python
+```python
class Solution:
def numWays(self, n: int) -> int:
if n == 0:
diff --git "a/Solutions/\345\211\221\346\214\207 Offer 11. \346\227\213\350\275\254\346\225\260\347\273\204\347\232\204\346\234\200\345\260\217\346\225\260\345\255\227.md" "b/Solutions/\345\211\221\346\214\207 Offer 11. \346\227\213\350\275\254\346\225\260\347\273\204\347\232\204\346\234\200\345\260\217\346\225\260\345\255\227.md"
index 07d67dfb..47240b4a 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer 11. \346\227\213\350\275\254\346\225\260\347\273\204\347\232\204\346\234\200\345\260\217\346\225\260\345\255\227.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer 11. \346\227\213\350\275\254\346\225\260\347\273\204\347\232\204\346\234\200\345\260\217\346\225\260\345\255\227.md"
@@ -47,7 +47,7 @@
## 代码
-```Python
+```python
class Solution:
def minArray(self, numbers: List[int]) -> int:
left = 0
diff --git "a/Solutions/\345\211\221\346\214\207 Offer 12. \347\237\251\351\230\265\344\270\255\347\232\204\350\267\257\345\276\204.md" "b/Solutions/\345\211\221\346\214\207 Offer 12. \347\237\251\351\230\265\344\270\255\347\232\204\350\267\257\345\276\204.md"
index c40cf3a7..36d4f565 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer 12. \347\237\251\351\230\265\344\270\255\347\232\204\350\267\257\345\276\204.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer 12. \347\237\251\351\230\265\344\270\255\347\232\204\350\267\257\345\276\204.md"
@@ -19,7 +19,7 @@
## 代码
-```Python
+```python
class Solution:
def exist(self, board: List[List[str]], word: str) -> bool:
directs = [(0, 1), (0, -1), (1, 0), (-1, 0)]
diff --git "a/Solutions/\345\211\221\346\214\207 Offer 13. \346\234\272\345\231\250\344\272\272\347\232\204\350\277\220\345\212\250\350\214\203\345\233\264.md" "b/Solutions/\345\211\221\346\214\207 Offer 13. \346\234\272\345\231\250\344\272\272\347\232\204\350\277\220\345\212\250\350\214\203\345\233\264.md"
index bd0cfdcc..c71ace25 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer 13. \346\234\272\345\231\250\344\272\272\347\232\204\350\277\220\345\212\250\350\214\203\345\233\264.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer 13. \346\234\272\345\231\250\344\272\272\347\232\204\350\277\220\345\212\250\350\214\203\345\233\264.md"
@@ -18,14 +18,14 @@
- 示例 1:
-```Python
+```python
输入:m = 2, n = 3, k = 1
输出:3
```
- 示例 2:
-```Python
+```python
输入:m = 3, n = 1, k = 0
输出:1
```
@@ -45,7 +45,7 @@
### 思路 1:代码
-```Python
+```python
import collections
class Solution:
diff --git "a/Solutions/\345\211\221\346\214\207 Offer 14- I. \345\211\252\347\273\263\345\255\220.md" "b/Solutions/\345\211\221\346\214\207 Offer 14- I. \345\211\252\347\273\263\345\255\220.md"
index a5a53325..5d7ef088 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer 14- I. \345\211\252\347\273\263\345\255\220.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer 14- I. \345\211\252\347\273\263\345\255\220.md"
@@ -28,7 +28,7 @@
## 代码
-```Python
+```python
class Solution:
def cuttingRope(self, n: int) -> int:
dp = [0 for _ in range(n + 1)]
diff --git "a/Solutions/\345\211\221\346\214\207 Offer 15. \344\272\214\350\277\233\345\210\266\344\270\2551\347\232\204\344\270\252\346\225\260.md" "b/Solutions/\345\211\221\346\214\207 Offer 15. \344\272\214\350\277\233\345\210\266\344\270\2551\347\232\204\344\270\252\346\225\260.md"
index 2db0f00f..53bd3772 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer 15. \344\272\214\350\277\233\345\210\266\344\270\2551\347\232\204\344\270\252\346\225\260.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer 15. \344\272\214\350\277\233\345\210\266\344\270\2551\347\232\204\344\270\252\346\225\260.md"
@@ -25,7 +25,7 @@
1. 循环按位计算
-```Python
+```python
class Solution:
def hammingWeight(self, n: int) -> int:
ans = 0
@@ -37,7 +37,7 @@ class Solution:
2. 改进位运算
-```Python
+```python
class Solution:
def hammingWeight(self, n: int) -> int:
ans = 0
diff --git "a/Solutions/\345\211\221\346\214\207 Offer 16. \346\225\260\345\200\274\347\232\204\346\225\264\346\225\260\346\254\241\346\226\271.md" "b/Solutions/\345\211\221\346\214\207 Offer 16. \346\225\260\345\200\274\347\232\204\346\225\264\346\225\260\346\254\241\346\226\271.md"
index c9189be2..df97e6f5 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer 16. \346\225\260\345\200\274\347\232\204\346\225\264\346\225\260\346\254\241\346\226\271.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer 16. \346\225\260\345\200\274\347\232\204\346\225\264\346\225\260\346\254\241\346\226\271.md"
@@ -23,7 +23,7 @@ $x^(n/2)$ 又可以继续向下递归划分。则我们可以利用低纬度的
## 代码
-```Python
+```python
class Solution:
def myPow(self, x: float, n: int) -> float:
if x == 0.0:
diff --git "a/Solutions/\345\211\221\346\214\207 Offer 17. \346\211\223\345\215\260\344\273\2161\345\210\260\346\234\200\345\244\247\347\232\204n\344\275\215\346\225\260.md" "b/Solutions/\345\211\221\346\214\207 Offer 17. \346\211\223\345\215\260\344\273\2161\345\210\260\346\234\200\345\244\247\347\232\204n\344\275\215\346\225\260.md"
index a7e75a40..4634b991 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer 17. \346\211\223\345\215\260\344\273\2161\345\210\260\346\234\200\345\244\247\347\232\204n\344\275\215\346\225\260.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer 17. \346\211\223\345\215\260\344\273\2161\345\210\260\346\234\200\345\244\247\347\232\204n\344\275\215\346\225\260.md"
@@ -15,7 +15,7 @@
## 代码
-```Python
+```python
class Solution:
def printNumbers(self, n: int) -> List[int]:
return [i for i in range(1, 10 ** n)]
diff --git "a/Solutions/\345\211\221\346\214\207 Offer 18. \345\210\240\351\231\244\351\223\276\350\241\250\347\232\204\350\212\202\347\202\271.md" "b/Solutions/\345\211\221\346\214\207 Offer 18. \345\210\240\351\231\244\351\223\276\350\241\250\347\232\204\350\212\202\347\202\271.md"
index 2a30c479..fc49ce81 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer 18. \345\210\240\351\231\244\351\223\276\350\241\250\347\232\204\350\212\202\347\202\271.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer 18. \345\210\240\351\231\244\351\223\276\350\241\250\347\232\204\350\212\202\347\202\271.md"
@@ -17,7 +17,7 @@
## 代码
-```Python
+```python
class Solution:
def deleteNode(self, head: ListNode, val: int) -> ListNode:
newHead = ListNode(0, head)
diff --git "a/Solutions/\345\211\221\346\214\207 Offer 21. \350\260\203\346\225\264\346\225\260\347\273\204\351\241\272\345\272\217\344\275\277\345\245\207\346\225\260\344\275\215\344\272\216\345\201\266\346\225\260\345\211\215\351\235\242.md" "b/Solutions/\345\211\221\346\214\207 Offer 21. \350\260\203\346\225\264\346\225\260\347\273\204\351\241\272\345\272\217\344\275\277\345\245\207\346\225\260\344\275\215\344\272\216\345\201\266\346\225\260\345\211\215\351\235\242.md"
index 7e2885c6..233f5f0a 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer 21. \350\260\203\346\225\264\346\225\260\347\273\204\351\241\272\345\272\217\344\275\277\345\245\207\346\225\260\344\275\215\344\272\216\345\201\266\346\225\260\345\211\215\351\235\242.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer 21. \350\260\203\346\225\264\346\225\260\347\273\204\351\241\272\345\272\217\344\275\277\345\245\207\346\225\260\344\275\215\344\272\216\345\201\266\346\225\260\345\211\215\351\235\242.md"
@@ -19,7 +19,7 @@
## 代码
-```Python
+```python
class Solution:
def exchange(self, nums: List[int]) -> List[int]:
slow, fast = 0, 0
diff --git "a/Solutions/\345\211\221\346\214\207 Offer 22. \351\223\276\350\241\250\344\270\255\345\200\222\346\225\260\347\254\254k\344\270\252\350\212\202\347\202\271.md" "b/Solutions/\345\211\221\346\214\207 Offer 22. \351\223\276\350\241\250\344\270\255\345\200\222\346\225\260\347\254\254k\344\270\252\350\212\202\347\202\271.md"
index 0c8ac1c5..18095d9a 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer 22. \351\223\276\350\241\250\344\270\255\345\200\222\346\225\260\347\254\254k\344\270\252\350\212\202\347\202\271.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer 22. \351\223\276\350\241\250\344\270\255\345\200\222\346\225\260\347\254\254k\344\270\252\350\212\202\347\202\271.md"
@@ -17,7 +17,7 @@
## 代码
-```Python
+```python
class Solution:
def getKthFromEnd(self, head: ListNode, k: int) -> ListNode:
slow = head
diff --git "a/Solutions/\345\211\221\346\214\207 Offer 24. \345\217\215\350\275\254\351\223\276\350\241\250.md" "b/Solutions/\345\211\221\346\214\207 Offer 24. \345\217\215\350\275\254\351\223\276\350\241\250.md"
index d6fc4e39..2dadb2da 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer 24. \345\217\215\350\275\254\351\223\276\350\241\250.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer 24. \345\217\215\350\275\254\351\223\276\350\241\250.md"
@@ -47,7 +47,7 @@
1. 迭代
-```Python
+```python
class Solution:
def reverseList(self, head: ListNode) -> ListNode:
pre = None
@@ -62,7 +62,7 @@ class Solution:
2. 递归
-```Python
+```python
class Solution:
def reverseList(self, head: ListNode) -> ListNode:
if head == None or head.next == None:
diff --git "a/Solutions/\345\211\221\346\214\207 Offer 25. \345\220\210\345\271\266\344\270\244\344\270\252\346\216\222\345\272\217\347\232\204\351\223\276\350\241\250.md" "b/Solutions/\345\211\221\346\214\207 Offer 25. \345\220\210\345\271\266\344\270\244\344\270\252\346\216\222\345\272\217\347\232\204\351\223\276\350\241\250.md"
index 3035d336..ab99337b 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer 25. \345\220\210\345\271\266\344\270\244\344\270\252\346\216\222\345\272\217\347\232\204\351\223\276\350\241\250.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer 25. \345\220\210\345\271\266\344\270\244\344\270\252\346\216\222\345\272\217\347\232\204\351\223\276\350\241\250.md"
@@ -23,7 +23,7 @@
## 代码
-```Python
+```python
class Solution:
def mergeTwoLists(self, l1: ListNode, l2: ListNode) -> ListNode:
newHead = ListNode(-1)
diff --git "a/Solutions/\345\211\221\346\214\207 Offer 26. \346\240\221\347\232\204\345\255\220\347\273\223\346\236\204.md" "b/Solutions/\345\211\221\346\214\207 Offer 26. \346\240\221\347\232\204\345\255\220\347\273\223\346\236\204.md"
index 230ea9fd..ce24142f 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer 26. \346\240\221\347\232\204\345\255\220\347\273\223\346\236\204.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer 26. \346\240\221\347\232\204\345\255\220\347\273\223\346\236\204.md"
@@ -28,7 +28,7 @@
## 代码
-```Python
+```python
class Solution:
def hasSubStructure(self, A: TreeNode, B: TreeNode) -> bool:
if not B:
diff --git "a/Solutions/\345\211\221\346\214\207 Offer 27. \344\272\214\345\217\211\346\240\221\347\232\204\351\225\234\345\203\217.md" "b/Solutions/\345\211\221\346\214\207 Offer 27. \344\272\214\345\217\211\346\240\221\347\232\204\351\225\234\345\203\217.md"
index fbc4dee2..ec5a0f9d 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer 27. \344\272\214\345\217\211\346\240\221\347\232\204\351\225\234\345\203\217.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer 27. \344\272\214\345\217\211\346\240\221\347\232\204\351\225\234\345\203\217.md"
@@ -15,7 +15,7 @@
## 代码
-```Python
+```python
class Solution:
def mirrorTree(self, root: TreeNode) -> TreeNode:
if not root:
diff --git "a/Solutions/\345\211\221\346\214\207 Offer 28. \345\257\271\347\247\260\347\232\204\344\272\214\345\217\211\346\240\221.md" "b/Solutions/\345\211\221\346\214\207 Offer 28. \345\257\271\347\247\260\347\232\204\344\272\214\345\217\211\346\240\221.md"
index 15e1f552..f0b826ac 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer 28. \345\257\271\347\247\260\347\232\204\344\272\214\345\217\211\346\240\221.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer 28. \345\257\271\347\247\260\347\232\204\344\272\214\345\217\211\346\240\221.md"
@@ -15,7 +15,7 @@
## 代码
-```Python
+```python
class Solution:
def isSymmetric(self, root: TreeNode) -> bool:
if not root:
diff --git "a/Solutions/\345\211\221\346\214\207 Offer 29. \351\241\272\346\227\266\351\222\210\346\211\223\345\215\260\347\237\251\351\230\265.md" "b/Solutions/\345\211\221\346\214\207 Offer 29. \351\241\272\346\227\266\351\222\210\346\211\223\345\215\260\347\237\251\351\230\265.md"
index ff438c62..1d4e0cd6 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer 29. \351\241\272\346\227\266\351\222\210\346\211\223\345\215\260\347\237\251\351\230\265.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer 29. \351\241\272\346\227\266\351\222\210\346\211\223\345\215\260\347\237\251\351\230\265.md"
@@ -17,7 +17,7 @@
## 代码
-```Python
+```python
class Solution:
def spiralOrder(self, matrix: List[List[int]]) -> List[int]:
size_m = len(matrix)
diff --git "a/Solutions/\345\211\221\346\214\207 Offer 30. \345\214\205\345\220\253min\345\207\275\346\225\260\347\232\204\346\240\210.md" "b/Solutions/\345\211\221\346\214\207 Offer 30. \345\214\205\345\220\253min\345\207\275\346\225\260\347\232\204\346\240\210.md"
index 3acd6bbd..814ee3fa 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer 30. \345\214\205\345\220\253min\345\207\275\346\225\260\347\232\204\346\240\210.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer 30. \345\214\205\345\220\253min\345\207\275\346\225\260\347\232\204\346\240\210.md"
@@ -18,7 +18,7 @@
## 代码
-```Python
+```python
class MinStack:
def __init__(self):
diff --git "a/Solutions/\345\211\221\346\214\207 Offer 31. \346\240\210\347\232\204\345\216\213\345\205\245\343\200\201\345\274\271\345\207\272\345\272\217\345\210\227.md" "b/Solutions/\345\211\221\346\214\207 Offer 31. \346\240\210\347\232\204\345\216\213\345\205\245\343\200\201\345\274\271\345\207\272\345\272\217\345\210\227.md"
index d2dd3c88..8d83f5e4 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer 31. \346\240\210\347\232\204\345\216\213\345\205\245\343\200\201\345\274\271\345\207\272\345\272\217\345\210\227.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer 31. \346\240\210\347\232\204\345\216\213\345\205\245\343\200\201\345\274\271\345\207\272\345\272\217\345\210\227.md"
@@ -15,7 +15,7 @@
## 代码
-```Python
+```python
class Solution:
def validateStackSequences(self, pushed: List[int], popped: List[int]) -> bool:
stack = []
diff --git "a/Solutions/\345\211\221\346\214\207 Offer 32 - I. \344\273\216\344\270\212\345\210\260\344\270\213\346\211\223\345\215\260\344\272\214\345\217\211\346\240\221.md" "b/Solutions/\345\211\221\346\214\207 Offer 32 - I. \344\273\216\344\270\212\345\210\260\344\270\213\346\211\223\345\215\260\344\272\214\345\217\211\346\240\221.md"
index 65ab4e1b..5c2ae5c1 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer 32 - I. \344\273\216\344\270\212\345\210\260\344\270\213\346\211\223\345\215\260\344\272\214\345\217\211\346\240\221.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer 32 - I. \344\273\216\344\270\212\345\210\260\344\270\213\346\211\223\345\215\260\344\272\214\345\217\211\346\240\221.md"
@@ -22,7 +22,7 @@
## 代码
-```Python
+```python
class Solution:
def levelOrder(self, root: TreeNode) -> List[int]:
if not root:
diff --git "a/Solutions/\345\211\221\346\214\207 Offer 32 - II. \344\273\216\344\270\212\345\210\260\344\270\213\346\211\223\345\215\260\344\272\214\345\217\211\346\240\221 II.md" "b/Solutions/\345\211\221\346\214\207 Offer 32 - II. \344\273\216\344\270\212\345\210\260\344\270\213\346\211\223\345\215\260\344\272\214\345\217\211\346\240\221 II.md"
index b5a4f037..3d1109c5 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer 32 - II. \344\273\216\344\270\212\345\210\260\344\270\213\346\211\223\345\215\260\344\272\214\345\217\211\346\240\221 II.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer 32 - II. \344\273\216\344\270\212\345\210\260\344\270\213\346\211\223\345\215\260\344\272\214\345\217\211\346\240\221 II.md"
@@ -22,7 +22,7 @@
## 代码
-```Python
+```python
class Solution:
def levelOrder(self, root: TreeNode) -> List[List[int]]:
if not root:
diff --git "a/Solutions/\345\211\221\346\214\207 Offer 32 - III. \344\273\216\344\270\212\345\210\260\344\270\213\346\211\223\345\215\260\344\272\214\345\217\211\346\240\221 III.md" "b/Solutions/\345\211\221\346\214\207 Offer 32 - III. \344\273\216\344\270\212\345\210\260\344\270\213\346\211\223\345\215\260\344\272\214\345\217\211\346\240\221 III.md"
index 3d6f9516..55b7a19f 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer 32 - III. \344\273\216\344\270\212\345\210\260\344\270\213\346\211\223\345\215\260\344\272\214\345\217\211\346\240\221 III.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer 32 - III. \344\273\216\344\270\212\345\210\260\344\270\213\346\211\223\345\215\260\344\272\214\345\217\211\346\240\221 III.md"
@@ -33,7 +33,7 @@
## 代码
-```Python
+```python
import collections
class Solution:
diff --git "a/Solutions/\345\211\221\346\214\207 Offer 33. \344\272\214\345\217\211\346\220\234\347\264\242\346\240\221\347\232\204\345\220\216\345\272\217\351\201\215\345\216\206\345\272\217\345\210\227.md" "b/Solutions/\345\211\221\346\214\207 Offer 33. \344\272\214\345\217\211\346\220\234\347\264\242\346\240\221\347\232\204\345\220\216\345\272\217\351\201\215\345\216\206\345\272\217\345\210\227.md"
index 3de1ab0e..ee800db9 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer 33. \344\272\214\345\217\211\346\220\234\347\264\242\346\240\221\347\232\204\345\220\216\345\272\217\351\201\215\345\216\206\345\272\217\345\210\227.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer 33. \344\272\214\345\217\211\346\220\234\347\264\242\346\240\221\347\232\204\345\220\216\345\272\217\351\201\215\345\216\206\345\272\217\345\210\227.md"
@@ -21,7 +21,7 @@
## 代码
-```Python
+```python
class Solution:
def verifyPostorder(self, postorder: List[int]) -> bool:
def verify(left, right):
diff --git "a/Solutions/\345\211\221\346\214\207 Offer 34. \344\272\214\345\217\211\346\240\221\344\270\255\345\222\214\344\270\272\346\237\220\344\270\200\345\200\274\347\232\204\350\267\257\345\276\204.md" "b/Solutions/\345\211\221\346\214\207 Offer 34. \344\272\214\345\217\211\346\240\221\344\270\255\345\222\214\344\270\272\346\237\220\344\270\200\345\200\274\347\232\204\350\267\257\345\276\204.md"
index 4105d460..aaae05af 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer 34. \344\272\214\345\217\211\346\240\221\344\270\255\345\222\214\344\270\272\346\237\220\344\270\200\345\200\274\347\232\204\350\267\257\345\276\204.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer 34. \344\272\214\345\217\211\346\240\221\344\270\255\345\222\214\344\270\272\346\237\220\344\270\200\345\200\274\347\232\204\350\267\257\345\276\204.md"
@@ -15,7 +15,7 @@
## 代码
-```Python
+```python
class Solution:
def pathSum(self, root: TreeNode, target: int) -> List[List[int]]:
res = []
diff --git "a/Solutions/\345\211\221\346\214\207 Offer 35. \345\244\215\346\235\202\351\223\276\350\241\250\347\232\204\345\244\215\345\210\266.md" "b/Solutions/\345\211\221\346\214\207 Offer 35. \345\244\215\346\235\202\351\223\276\350\241\250\347\232\204\345\244\215\345\210\266.md"
index da0155b0..e55b808e 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer 35. \345\244\215\346\235\202\351\223\276\350\241\250\347\232\204\345\244\215\345\210\266.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer 35. \345\244\215\346\235\202\351\223\276\350\241\250\347\232\204\345\244\215\345\210\266.md"
@@ -17,7 +17,7 @@
## 代码
-```Python
+```python
class Solution:
def copyRandomList(self, head: 'Node') -> 'Node':
if not head:
diff --git "a/Solutions/\345\211\221\346\214\207 Offer 36. \344\272\214\345\217\211\346\220\234\347\264\242\346\240\221\344\270\216\345\217\214\345\220\221\351\223\276\350\241\250.md" "b/Solutions/\345\211\221\346\214\207 Offer 36. \344\272\214\345\217\211\346\220\234\347\264\242\346\240\221\344\270\216\345\217\214\345\220\221\351\223\276\350\241\250.md"
index 0b30a906..7c6b4aad 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer 36. \344\272\214\345\217\211\346\220\234\347\264\242\346\240\221\344\270\216\345\217\214\345\220\221\351\223\276\350\241\250.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer 36. \344\272\214\345\217\211\346\220\234\347\264\242\346\240\221\344\270\216\345\217\214\345\220\221\351\223\276\350\241\250.md"
@@ -26,7 +26,7 @@
## 代码
-```Python
+```python
class Solution:
def treeToDoublyList(self, root: 'Node') -> 'Node':
def dfs(node: 'Node'):
diff --git "a/Solutions/\345\211\221\346\214\207 Offer 37. \345\272\217\345\210\227\345\214\226\344\272\214\345\217\211\346\240\221.md" "b/Solutions/\345\211\221\346\214\207 Offer 37. \345\272\217\345\210\227\345\214\226\344\272\214\345\217\211\346\240\221.md"
index 5e91caba..170b5b5b 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer 37. \345\272\217\345\210\227\345\214\226\344\272\214\345\217\211\346\240\221.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer 37. \345\272\217\345\210\227\345\214\226\344\272\214\345\217\211\346\240\221.md"
@@ -28,7 +28,7 @@
## 代码
-```Python
+```python
class Codec:
def serialize(self, root):
diff --git "a/Solutions/\345\211\221\346\214\207 Offer 38. \345\255\227\347\254\246\344\270\262\347\232\204\346\216\222\345\210\227.md" "b/Solutions/\345\211\221\346\214\207 Offer 38. \345\255\227\347\254\246\344\270\262\347\232\204\346\216\222\345\210\227.md"
index cf705108..cd82c4fa 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer 38. \345\255\227\347\254\246\344\270\262\347\232\204\346\216\222\345\210\227.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer 38. \345\255\227\347\254\246\344\270\262\347\232\204\346\216\222\345\210\227.md"
@@ -19,7 +19,7 @@
## 代码
-```Python
+```python
class Solution:
res = []
path = []
diff --git "a/Solutions/\345\211\221\346\214\207 Offer 39. \346\225\260\347\273\204\344\270\255\345\207\272\347\216\260\346\254\241\346\225\260\350\266\205\350\277\207\344\270\200\345\215\212\347\232\204\346\225\260\345\255\227.md" "b/Solutions/\345\211\221\346\214\207 Offer 39. \346\225\260\347\273\204\344\270\255\345\207\272\347\216\260\346\254\241\346\225\260\350\266\205\350\277\207\344\270\200\345\215\212\347\232\204\346\225\260\345\255\227.md"
index d05fc035..9960eb2b 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer 39. \346\225\260\347\273\204\344\270\255\345\207\272\347\216\260\346\254\241\346\225\260\350\266\205\350\277\207\344\270\200\345\215\212\347\232\204\346\225\260\345\255\227.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer 39. \346\225\260\347\273\204\344\270\255\345\207\272\347\216\260\346\254\241\346\225\260\350\266\205\350\277\207\344\270\200\345\215\212\347\232\204\346\225\260\345\255\227.md"
@@ -15,7 +15,7 @@
## 代码
-```Python
+```python
class Solution:
def majorityElement(self, nums: List[int]) -> int:
numDict = dict()
diff --git "a/Solutions/\345\211\221\346\214\207 Offer 40. \346\234\200\345\260\217\347\232\204k\344\270\252\346\225\260.md" "b/Solutions/\345\211\221\346\214\207 Offer 40. \346\234\200\345\260\217\347\232\204k\344\270\252\346\225\260.md"
index 8b6e8db0..ee0f7359 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer 40. \346\234\200\345\260\217\347\232\204k\344\270\252\346\225\260.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer 40. \346\234\200\345\260\217\347\232\204k\344\270\252\346\225\260.md"
@@ -18,14 +18,14 @@
- 示例 1:
-```Python
+```python
输入:arr = [3,2,1], k = 2
输出:[1,2] 或者 [2,1]
```
- 示例 2:
-```Python
+```python
输入:arr = [0,1,2,1], k = 1
输出:[0]
```
@@ -48,7 +48,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def heapify(self, nums: [int], index: int, end: int):
left = index * 2 + 1
@@ -106,7 +106,7 @@ class Solution:
### 思路 2:代码
-```Python
+```python
import random
class Solution:
diff --git "a/Solutions/\345\211\221\346\214\207 Offer 41. \346\225\260\346\215\256\346\265\201\344\270\255\347\232\204\344\270\255\344\275\215\346\225\260.md" "b/Solutions/\345\211\221\346\214\207 Offer 41. \346\225\260\346\215\256\346\265\201\344\270\255\347\232\204\344\270\255\344\275\215\346\225\260.md"
index 80e3c7e1..1d1c8b39 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer 41. \346\225\260\346\215\256\346\265\201\344\270\255\347\232\204\344\270\255\344\275\215\346\225\260.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer 41. \346\225\260\346\215\256\346\265\201\344\270\255\347\232\204\344\270\255\344\275\215\346\225\260.md"
@@ -24,7 +24,7 @@
## 代码
-```Python
+```python
import heapq
class MedianFinder:
diff --git "a/Solutions/\345\211\221\346\214\207 Offer 42. \350\277\236\347\273\255\345\255\220\346\225\260\347\273\204\347\232\204\346\234\200\345\244\247\345\222\214.md" "b/Solutions/\345\211\221\346\214\207 Offer 42. \350\277\236\347\273\255\345\255\220\346\225\260\347\273\204\347\232\204\346\234\200\345\244\247\345\222\214.md"
index 16a7508a..10f1a8f9 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer 42. \350\277\236\347\273\255\345\255\220\346\225\260\347\273\204\347\232\204\346\234\200\345\244\247\345\222\214.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer 42. \350\277\236\347\273\255\345\255\220\346\225\260\347\273\204\347\232\204\346\234\200\345\244\247\345\222\214.md"
@@ -22,7 +22,7 @@
## 代码
-```Python
+```python
class Solution:
def maxSubArray(self, nums: List[int]) -> int:
max_ans = nums[0]
diff --git "a/Solutions/\345\211\221\346\214\207 Offer 44. \346\225\260\345\255\227\345\272\217\345\210\227\344\270\255\346\237\220\344\270\200\344\275\215\347\232\204\346\225\260\345\255\227.md" "b/Solutions/\345\211\221\346\214\207 Offer 44. \346\225\260\345\255\227\345\272\217\345\210\227\344\270\255\346\237\220\344\270\200\344\275\215\347\232\204\346\225\260\345\255\227.md"
index 23c67e83..bece89ad 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer 44. \346\225\260\345\255\227\345\272\217\345\210\227\344\270\255\346\237\220\344\270\200\344\275\215\347\232\204\346\225\260\345\255\227.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer 44. \346\225\260\345\255\227\345\272\217\345\210\227\344\270\255\346\237\220\344\270\200\344\275\215\347\232\204\346\225\260\345\255\227.md"
@@ -26,7 +26,7 @@
## 代码
-```Python
+```python
class Solution:
def findNthDigit(self, n: int) -> int:
digits = 1
diff --git "a/Solutions/\345\211\221\346\214\207 Offer 45. \346\212\212\346\225\260\347\273\204\346\216\222\346\210\220\346\234\200\345\260\217\347\232\204\346\225\260.md" "b/Solutions/\345\211\221\346\214\207 Offer 45. \346\212\212\346\225\260\347\273\204\346\216\222\346\210\220\346\234\200\345\260\217\347\232\204\346\225\260.md"
index cbcac152..18ef92d8 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer 45. \346\212\212\346\225\260\347\273\204\346\216\222\346\210\220\346\234\200\345\260\217\347\232\204\346\225\260.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer 45. \346\212\212\346\225\260\347\273\204\346\216\222\346\210\220\346\234\200\345\260\217\347\232\204\346\225\260.md"
@@ -19,7 +19,7 @@
- 示例 1:
-```Python
+```python
输入:[3,30,34,5,9]
输出:"3033459"
```
@@ -37,7 +37,7 @@
### 思路 1:自定义排序代码
-```Python
+```python
import functools
class Solution:
diff --git "a/Solutions/\345\211\221\346\214\207 Offer 46. \346\212\212\346\225\260\345\255\227\347\277\273\350\257\221\346\210\220\345\255\227\347\254\246\344\270\262.md" "b/Solutions/\345\211\221\346\214\207 Offer 46. \346\212\212\346\225\260\345\255\227\347\277\273\350\257\221\346\210\220\345\255\227\347\254\246\344\270\262.md"
index bd25f8ff..b1591d6f 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer 46. \346\212\212\346\225\260\345\255\227\347\277\273\350\257\221\346\210\220\345\255\227\347\254\246\344\270\262.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer 46. \346\212\212\346\225\260\345\255\227\347\277\273\350\257\221\346\210\220\345\255\227\347\254\246\344\270\262.md"
@@ -20,7 +20,7 @@
## 代码
-```Python
+```python
class Solution:
def translateNum(self, num: int) -> int:
s = str(num)
diff --git "a/Solutions/\345\211\221\346\214\207 Offer 47. \347\244\274\347\211\251\347\232\204\346\234\200\345\244\247\344\273\267\345\200\274.md" "b/Solutions/\345\211\221\346\214\207 Offer 47. \347\244\274\347\211\251\347\232\204\346\234\200\345\244\247\344\273\267\345\200\274.md"
index 2ea1a68e..d8c7f6c8 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer 47. \347\244\274\347\211\251\347\232\204\346\234\200\345\244\247\344\273\267\345\200\274.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer 47. \347\244\274\347\211\251\347\232\204\346\234\200\345\244\247\344\273\267\345\200\274.md"
@@ -19,7 +19,7 @@
## 代码
-```Python
+```python
class Solution:
def maxValue(self, grid: List[List[int]]) -> int:
if not grid:
diff --git "a/Solutions/\345\211\221\346\214\207 Offer 48. \346\234\200\351\225\277\344\270\215\345\220\253\351\207\215\345\244\215\345\255\227\347\254\246\347\232\204\345\255\220\345\255\227\347\254\246\344\270\262.md" "b/Solutions/\345\211\221\346\214\207 Offer 48. \346\234\200\351\225\277\344\270\215\345\220\253\351\207\215\345\244\215\345\255\227\347\254\246\347\232\204\345\255\220\345\255\227\347\254\246\344\270\262.md"
index a5bd729d..1026fc25 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer 48. \346\234\200\351\225\277\344\270\215\345\220\253\351\207\215\345\244\215\345\255\227\347\254\246\347\232\204\345\255\220\345\255\227\347\254\246\344\270\262.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer 48. \346\234\200\351\225\277\344\270\215\345\220\253\351\207\215\345\244\215\345\255\227\347\254\246\347\232\204\345\255\220\345\255\227\347\254\246\344\270\262.md"
@@ -15,7 +15,7 @@
## 代码
-```Python
+```python
class Solution:
def lengthOfLongestSubstring(self, s: str) -> int:
if not s:
diff --git "a/Solutions/\345\211\221\346\214\207 Offer 49. \344\270\221\346\225\260.md" "b/Solutions/\345\211\221\346\214\207 Offer 49. \344\270\221\346\225\260.md"
index 9694629f..50d736b3 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer 49. \344\270\221\346\225\260.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer 49. \344\270\221\346\225\260.md"
@@ -21,7 +21,7 @@
## 代码
-```Python
+```python
class Solution:
def nthUglyNumber(self, n: int) -> int:
dp = [1 for _ in range(n)]
diff --git "a/Solutions/\345\211\221\346\214\207 Offer 50. \347\254\254\344\270\200\344\270\252\345\217\252\345\207\272\347\216\260\344\270\200\346\254\241\347\232\204\345\255\227\347\254\246.md" "b/Solutions/\345\211\221\346\214\207 Offer 50. \347\254\254\344\270\200\344\270\252\345\217\252\345\207\272\347\216\260\344\270\200\346\254\241\347\232\204\345\255\227\347\254\246.md"
index 0c4f62e8..25c0698f 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer 50. \347\254\254\344\270\200\344\270\252\345\217\252\345\207\272\347\216\260\344\270\200\346\254\241\347\232\204\345\255\227\347\254\246.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer 50. \347\254\254\344\270\200\344\270\252\345\217\252\345\207\272\347\216\260\344\270\200\346\254\241\347\232\204\345\255\227\347\254\246.md"
@@ -17,7 +17,7 @@
## 代码
-```Python
+```python
class Solution:
def firstUniqChar(self, s: str) -> str:
dic = dict()
diff --git "a/Solutions/\345\211\221\346\214\207 Offer 51. \346\225\260\347\273\204\344\270\255\347\232\204\351\200\206\345\272\217\345\257\271.md" "b/Solutions/\345\211\221\346\214\207 Offer 51. \346\225\260\347\273\204\344\270\255\347\232\204\351\200\206\345\272\217\345\257\271.md"
index 1c66e5f7..0cfa49c8 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer 51. \346\225\260\347\273\204\344\270\255\347\232\204\351\200\206\345\272\217\345\257\271.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer 51. \346\225\260\347\273\204\344\270\255\347\232\204\351\200\206\345\272\217\345\257\271.md"
@@ -18,7 +18,7 @@
- 示例 1:
-```Python
+```python
输入: [7,5,6,4]
输出: 5
```
@@ -55,7 +55,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
cnt = 0
def merge(self, left_arr, right_arr): # 归并过程
@@ -112,7 +112,7 @@ class Solution:
### 思路 2:代码
-```Python
+```python
import bisect
class BinaryIndexTree:
diff --git "a/Solutions/\345\211\221\346\214\207 Offer 52. \344\270\244\344\270\252\351\223\276\350\241\250\347\232\204\347\254\254\344\270\200\344\270\252\345\205\254\345\205\261\350\212\202\347\202\271.md" "b/Solutions/\345\211\221\346\214\207 Offer 52. \344\270\244\344\270\252\351\223\276\350\241\250\347\232\204\347\254\254\344\270\200\344\270\252\345\205\254\345\205\261\350\212\202\347\202\271.md"
index d66fb473..cf02094c 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer 52. \344\270\244\344\270\252\351\223\276\350\241\250\347\232\204\347\254\254\344\270\200\344\270\252\345\205\254\345\205\261\350\212\202\347\202\271.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer 52. \344\270\244\344\270\252\351\223\276\350\241\250\347\232\204\347\254\254\344\270\200\344\270\252\345\205\254\345\205\261\350\212\202\347\202\271.md"
@@ -29,7 +29,7 @@
## 代码
-```Python
+```python
class Solution:
def getIntersectionNode(self, headA: ListNode, headB: ListNode) -> ListNode:
if not headA or not headB:
diff --git "a/Solutions/\345\211\221\346\214\207 Offer 53 - I. \345\234\250\346\216\222\345\272\217\346\225\260\347\273\204\344\270\255\346\237\245\346\211\276\346\225\260\345\255\227 I.md" "b/Solutions/\345\211\221\346\214\207 Offer 53 - I. \345\234\250\346\216\222\345\272\217\346\225\260\347\273\204\344\270\255\346\237\245\346\211\276\346\225\260\345\255\227 I.md"
index 87c83ac7..0bd81eba 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer 53 - I. \345\234\250\346\216\222\345\272\217\346\225\260\347\273\204\344\270\255\346\237\245\346\211\276\346\225\260\345\255\227 I.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer 53 - I. \345\234\250\346\216\222\345\272\217\346\225\260\347\273\204\344\270\255\346\237\245\346\211\276\346\225\260\345\255\227 I.md"
@@ -19,7 +19,7 @@
## 代码
-```Python
+```python
class Solution:
def searchLeft(self, nums, target):
left, right = 0, len(nums) - 1
diff --git "a/Solutions/\345\211\221\346\214\207 Offer 53 - II. 0\357\275\236n-1\344\270\255\347\274\272\345\244\261\347\232\204\346\225\260\345\255\227.md" "b/Solutions/\345\211\221\346\214\207 Offer 53 - II. 0\357\275\236n-1\344\270\255\347\274\272\345\244\261\347\232\204\346\225\260\345\255\227.md"
index 71d0e287..ce4f6aeb 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer 53 - II. 0\357\275\236n-1\344\270\255\347\274\272\345\244\261\347\232\204\346\225\260\345\255\227.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer 53 - II. 0\357\275\236n-1\344\270\255\347\274\272\345\244\261\347\232\204\346\225\260\345\255\227.md"
@@ -17,7 +17,7 @@
## 代码
-```Python
+```python
class Solution:
def missingNumber(self, nums: List[int]) -> int:
if len(nums) == 0:
diff --git "a/Solutions/\345\211\221\346\214\207 Offer 54. \344\272\214\345\217\211\346\220\234\347\264\242\346\240\221\347\232\204\347\254\254k\345\244\247\350\212\202\347\202\271.md" "b/Solutions/\345\211\221\346\214\207 Offer 54. \344\272\214\345\217\211\346\220\234\347\264\242\346\240\221\347\232\204\347\254\254k\345\244\247\350\212\202\347\202\271.md"
index 3d8cd472..630a97c6 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer 54. \344\272\214\345\217\211\346\220\234\347\264\242\346\240\221\347\232\204\347\254\254k\345\244\247\350\212\202\347\202\271.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer 54. \344\272\214\345\217\211\346\220\234\347\264\242\346\240\221\347\232\204\347\254\254k\345\244\247\350\212\202\347\202\271.md"
@@ -17,7 +17,7 @@
## 代码
-```Python
+```python
class Solution:
res = 0
k = 0
diff --git "a/Solutions/\345\211\221\346\214\207 Offer 55 - I. \344\272\214\345\217\211\346\240\221\347\232\204\346\267\261\345\272\246.md" "b/Solutions/\345\211\221\346\214\207 Offer 55 - I. \344\272\214\345\217\211\346\240\221\347\232\204\346\267\261\345\272\246.md"
index 8c186482..6f5bc72e 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer 55 - I. \344\272\214\345\217\211\346\240\221\347\232\204\346\267\261\345\272\246.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer 55 - I. \344\272\214\345\217\211\346\240\221\347\232\204\346\267\261\345\272\246.md"
@@ -17,7 +17,7 @@
## 代码
-```Python
+```python
class Solution:
def maxDepth(self, root: TreeNode) -> int:
if root == None:
diff --git "a/Solutions/\345\211\221\346\214\207 Offer 55 - II. \345\271\263\350\241\241\344\272\214\345\217\211\346\240\221.md" "b/Solutions/\345\211\221\346\214\207 Offer 55 - II. \345\271\263\350\241\241\344\272\214\345\217\211\346\240\221.md"
index cc7af228..7342d8c9 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer 55 - II. \345\271\263\350\241\241\344\272\214\345\217\211\346\240\221.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer 55 - II. \345\271\263\350\241\241\344\272\214\345\217\211\346\240\221.md"
@@ -21,7 +21,7 @@
## 代码
-```Python
+```python
class Solution:
def isBalanced(self, root: TreeNode) -> bool:
def height(root: TreeNode) -> int:
diff --git "a/Solutions/\345\211\221\346\214\207 Offer 56 - I. \346\225\260\347\273\204\344\270\255\346\225\260\345\255\227\345\207\272\347\216\260\347\232\204\346\254\241\346\225\260.md" "b/Solutions/\345\211\221\346\214\207 Offer 56 - I. \346\225\260\347\273\204\344\270\255\346\225\260\345\255\227\345\207\272\347\216\260\347\232\204\346\254\241\346\225\260.md"
index b8299756..b099901a 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer 56 - I. \346\225\260\347\273\204\344\270\255\346\225\260\345\255\227\345\207\272\347\216\260\347\232\204\346\254\241\346\225\260.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer 56 - I. \346\225\260\347\273\204\344\270\255\346\225\260\345\255\227\345\207\272\347\216\260\347\232\204\346\254\241\346\225\260.md"
@@ -18,7 +18,7 @@
## 代码
-```Python
+```python
class Solution:
def singleNumbers(self, nums: List[int]) -> List[int]:
all_xor = 0
diff --git "a/Solutions/\345\211\221\346\214\207 Offer 57 - II. \345\222\214\344\270\272s\347\232\204\350\277\236\347\273\255\346\255\243\346\225\260\345\272\217\345\210\227.md" "b/Solutions/\345\211\221\346\214\207 Offer 57 - II. \345\222\214\344\270\272s\347\232\204\350\277\236\347\273\255\346\255\243\346\225\260\345\272\217\345\210\227.md"
index 1eae5a76..8571b729 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer 57 - II. \345\222\214\344\270\272s\347\232\204\350\277\236\347\273\255\346\255\243\346\225\260\345\272\217\345\210\227.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer 57 - II. \345\222\214\344\270\272s\347\232\204\350\277\236\347\273\255\346\255\243\346\225\260\345\272\217\345\210\227.md"
@@ -17,14 +17,14 @@
- 示例 1:
-```Python
+```python
输入:target = 9
输出:[[2,3,4],[4,5]]
```
- 示例 2:
-```Python
+```python
输入:target = 15
输出:[[1,2,3,4,5],[4,5,6],[7,8]]
```
@@ -49,7 +49,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def findContinuousSequence(self, target: int) -> List[List[int]]:
res = []
@@ -86,7 +86,7 @@ class Solution:
### 思路 2:滑动窗口代码
-```Python
+```python
class Solution:
def findContinuousSequence(self, target: int) -> List[List[int]]:
left, right = 1, 2
diff --git "a/Solutions/\345\211\221\346\214\207 Offer 57. \345\222\214\344\270\272s\347\232\204\344\270\244\344\270\252\346\225\260\345\255\227.md" "b/Solutions/\345\211\221\346\214\207 Offer 57. \345\222\214\344\270\272s\347\232\204\344\270\244\344\270\252\346\225\260\345\255\227.md"
index 12b06781..6ff5eebf 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer 57. \345\222\214\344\270\272s\347\232\204\344\270\244\344\270\252\346\225\260\345\255\227.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer 57. \345\222\214\344\270\272s\347\232\204\344\270\244\344\270\252\346\225\260\345\255\227.md"
@@ -20,7 +20,7 @@
## 代码
-```Python
+```python
class Solution:
def twoSum(self, nums: List[int], target: int) -> List[int]:
left, right = 0, len(nums) - 1
diff --git "a/Solutions/\345\211\221\346\214\207 Offer 58 - I. \347\277\273\350\275\254\345\215\225\350\257\215\351\241\272\345\272\217.md" "b/Solutions/\345\211\221\346\214\207 Offer 58 - I. \347\277\273\350\275\254\345\215\225\350\257\215\351\241\272\345\272\217.md"
index 5f6c35e4..06a4075f 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer 58 - I. \347\277\273\350\275\254\345\215\225\350\257\215\351\241\272\345\272\217.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer 58 - I. \347\277\273\350\275\254\345\215\225\350\257\215\351\241\272\345\272\217.md"
@@ -21,7 +21,7 @@
## 代码
-```Python
+```python
class Solution:
def reverseWords(self, s: str) -> str:
return " ".join(reversed(s.split()))
diff --git "a/Solutions/\345\211\221\346\214\207 Offer 58 - II. \345\267\246\346\227\213\350\275\254\345\255\227\347\254\246\344\270\262.md" "b/Solutions/\345\211\221\346\214\207 Offer 58 - II. \345\267\246\346\227\213\350\275\254\345\255\227\347\254\246\344\270\262.md"
index 7107fd39..a1e45898 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer 58 - II. \345\267\246\346\227\213\350\275\254\345\255\227\347\254\246\344\270\262.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer 58 - II. \345\267\246\346\227\213\350\275\254\345\255\227\347\254\246\344\270\262.md"
@@ -20,7 +20,7 @@
## 代码
-```Python
+```python
class Solution:
def reverseLeftWords(self, s: str, n: int) -> str:
res = []
diff --git "a/Solutions/\345\211\221\346\214\207 Offer 59 - I. \346\273\221\345\212\250\347\252\227\345\217\243\347\232\204\346\234\200\345\244\247\345\200\274.md" "b/Solutions/\345\211\221\346\214\207 Offer 59 - I. \346\273\221\345\212\250\347\252\227\345\217\243\347\232\204\346\234\200\345\244\247\345\200\274.md"
index 94fdb331..cb4b252c 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer 59 - I. \346\273\221\345\212\250\347\252\227\345\217\243\347\232\204\346\234\200\345\244\247\345\200\274.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer 59 - I. \346\273\221\345\212\250\347\252\227\345\217\243\347\232\204\346\234\200\345\244\247\345\200\274.md"
@@ -17,7 +17,7 @@
## 代码
-```Python
+```python
class Solution:
def maxSlidingWindow(self, nums: List[int], k: int) -> List[int]:
size = len(nums)
diff --git "a/Solutions/\345\211\221\346\214\207 Offer 59 - II. \351\230\237\345\210\227\347\232\204\346\234\200\345\244\247\345\200\274.md" "b/Solutions/\345\211\221\346\214\207 Offer 59 - II. \351\230\237\345\210\227\347\232\204\346\234\200\345\244\247\345\200\274.md"
index cbcf3c3a..145e5166 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer 59 - II. \351\230\237\345\210\227\347\232\204\346\234\200\345\244\247\345\200\274.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer 59 - II. \351\230\237\345\210\227\347\232\204\346\234\200\345\244\247\345\200\274.md"
@@ -17,7 +17,7 @@
## 代码
-```Python
+```python
import collections
import queue
diff --git "a/Solutions/\345\211\221\346\214\207 Offer 61. \346\211\221\345\205\213\347\211\214\344\270\255\347\232\204\351\241\272\345\255\220.md" "b/Solutions/\345\211\221\346\214\207 Offer 61. \346\211\221\345\205\213\347\211\214\344\270\255\347\232\204\351\241\272\345\255\220.md"
index 23c8f084..94a30fb0 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer 61. \346\211\221\345\205\213\347\211\214\344\270\255\347\232\204\351\241\272\345\255\220.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer 61. \346\211\221\345\205\213\347\211\214\344\270\255\347\232\204\351\241\272\345\255\220.md"
@@ -23,7 +23,7 @@
## 代码
-```Python
+```python
class Solution:
def isStraight(self, nums: List[int]) -> bool:
max_num, min_num = 0, 14
diff --git "a/Solutions/\345\211\221\346\214\207 Offer 62. \345\234\206\345\234\210\344\270\255\346\234\200\345\220\216\345\211\251\344\270\213\347\232\204\346\225\260\345\255\227.md" "b/Solutions/\345\211\221\346\214\207 Offer 62. \345\234\206\345\234\210\344\270\255\346\234\200\345\220\216\345\211\251\344\270\213\347\232\204\346\225\260\345\255\227.md"
index 34c45510..b52cf489 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer 62. \345\234\206\345\234\210\344\270\255\346\234\200\345\220\216\345\211\251\344\270\213\347\232\204\346\225\260\345\255\227.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer 62. \345\234\206\345\234\210\344\270\255\346\234\200\345\220\216\345\211\251\344\270\213\347\232\204\346\225\260\345\255\227.md"
@@ -41,7 +41,7 @@
## 代码
-```Python
+```python
class Solution:
def lastRemaining(self, n: int, m: int) -> int:
ans = 0
diff --git "a/Solutions/\345\211\221\346\214\207 Offer 63. \350\202\241\347\245\250\347\232\204\346\234\200\345\244\247\345\210\251\346\266\246.md" "b/Solutions/\345\211\221\346\214\207 Offer 63. \350\202\241\347\245\250\347\232\204\346\234\200\345\244\247\345\210\251\346\266\246.md"
index 66eda42c..9e4c9eaf 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer 63. \350\202\241\347\245\250\347\232\204\346\234\200\345\244\247\345\210\251\346\266\246.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer 63. \350\202\241\347\245\250\347\232\204\346\234\200\345\244\247\345\210\251\346\266\246.md"
@@ -17,7 +17,7 @@
## 代码
-```Python
+```python
class Solution:
def maxProfit(self, prices: List[int]) -> int:
minprice = 10010
diff --git "a/Solutions/\345\211\221\346\214\207 Offer 64. \346\261\2021+2+\342\200\246+n.md" "b/Solutions/\345\211\221\346\214\207 Offer 64. \346\261\2021+2+\342\200\246+n.md"
index a6104bd7..85ee476e 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer 64. \346\261\2021+2+\342\200\246+n.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer 64. \346\261\2021+2+\342\200\246+n.md"
@@ -15,7 +15,7 @@ Python 中的逻辑运算最终返回的是最后一个非空值。比如 `3 and
## 代码
-```Python
+```python
class Solution:
def sumNums(self, n: int) -> int:
return n and n + self.sumNums(n - 1)
diff --git "a/Solutions/\345\211\221\346\214\207 Offer 65. \344\270\215\347\224\250\345\212\240\345\207\217\344\271\230\351\231\244\345\201\232\345\212\240\346\263\225.md" "b/Solutions/\345\211\221\346\214\207 Offer 65. \344\270\215\347\224\250\345\212\240\345\207\217\344\271\230\351\231\244\345\201\232\345\212\240\346\263\225.md"
index 65fe76fa..045a7bd3 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer 65. \344\270\215\347\224\250\345\212\240\345\207\217\344\271\230\351\231\244\345\201\232\345\212\240\346\263\225.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer 65. \344\270\215\347\224\250\345\212\240\345\207\217\344\271\230\351\231\244\345\201\232\345\212\240\346\263\225.md"
@@ -29,7 +29,7 @@
## 代码
-```Python
+```python
class Solution:
def getSum(self, a: int, b: int) -> int:
MAX_INT = 0x7FFFFFFF
diff --git "a/Solutions/\345\211\221\346\214\207 Offer 66. \346\236\204\345\273\272\344\271\230\347\247\257\346\225\260\347\273\204.md" "b/Solutions/\345\211\221\346\214\207 Offer 66. \346\236\204\345\273\272\344\271\230\347\247\257\346\225\260\347\273\204.md"
index 66ee8be2..18d912c7 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer 66. \346\236\204\345\273\272\344\271\230\347\247\257\346\225\260\347\273\204.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer 66. \346\236\204\345\273\272\344\271\230\347\247\257\346\225\260\347\273\204.md"
@@ -17,7 +17,7 @@
## 代码
-```Python
+```python
class Solution:
def constructArr(self, a: List[int]) -> List[int]:
size = len(a)
diff --git "a/Solutions/\345\211\221\346\214\207 Offer 67. \346\212\212\345\255\227\347\254\246\344\270\262\350\275\254\346\215\242\346\210\220\346\225\264\346\225\260.md" "b/Solutions/\345\211\221\346\214\207 Offer 67. \346\212\212\345\255\227\347\254\246\344\270\262\350\275\254\346\215\242\346\210\220\346\225\264\346\225\260.md"
index 0e0546d0..19082b10 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer 67. \346\212\212\345\255\227\347\254\246\344\270\262\350\275\254\346\215\242\346\210\220\346\225\264\346\225\260.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer 67. \346\212\212\345\255\227\347\254\246\344\270\262\350\275\254\346\215\242\346\210\220\346\225\264\346\225\260.md"
@@ -28,7 +28,7 @@
## 代码
-```Python
+```python
class Solution:
def strToInt(self, str: str) -> int:
num_str = ""
diff --git "a/Solutions/\345\211\221\346\214\207 Offer 68 - I. \344\272\214\345\217\211\346\220\234\347\264\242\346\240\221\347\232\204\346\234\200\350\277\221\345\205\254\345\205\261\347\245\226\345\205\210.md" "b/Solutions/\345\211\221\346\214\207 Offer 68 - I. \344\272\214\345\217\211\346\220\234\347\264\242\346\240\221\347\232\204\346\234\200\350\277\221\345\205\254\345\205\261\347\245\226\345\205\210.md"
index 684334bb..90f5c973 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer 68 - I. \344\272\214\345\217\211\346\220\234\347\264\242\346\240\221\347\232\204\346\234\200\350\277\221\345\205\254\345\205\261\347\245\226\345\205\210.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer 68 - I. \344\272\214\345\217\211\346\220\234\347\264\242\346\240\221\347\232\204\346\234\200\350\277\221\345\205\254\345\205\261\347\245\226\345\205\210.md"
@@ -25,7 +25,7 @@
## 代码
-```Python
+```python
class Solution:
def lowestCommonAncestor(self, root: 'TreeNode', p: 'TreeNode', q: 'TreeNode') -> 'TreeNode':
ancestor = root
diff --git "a/Solutions/\345\211\221\346\214\207 Offer 68 - II. \344\272\214\345\217\211\346\240\221\347\232\204\346\234\200\350\277\221\345\205\254\345\205\261\347\245\226\345\205\210.md" "b/Solutions/\345\211\221\346\214\207 Offer 68 - II. \344\272\214\345\217\211\346\240\221\347\232\204\346\234\200\350\277\221\345\205\254\345\205\261\347\245\226\345\205\210.md"
index 9d34588b..38412714 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer 68 - II. \344\272\214\345\217\211\346\240\221\347\232\204\346\234\200\350\277\221\345\205\254\345\205\261\347\245\226\345\205\210.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer 68 - II. \344\272\214\345\217\211\346\240\221\347\232\204\346\234\200\350\277\221\345\205\254\345\205\261\347\245\226\345\205\210.md"
@@ -38,7 +38,7 @@
## 代码
-```Python
+```python
class Solution:
def lowestCommonAncestor(self, root: TreeNode, p: TreeNode, q: TreeNode) -> TreeNode:
if root == p or root == q:
diff --git "a/Solutions/\345\211\221\346\214\207 Offer II 001. \346\225\264\346\225\260\351\231\244\346\263\225.md" "b/Solutions/\345\211\221\346\214\207 Offer II 001. \346\225\264\346\225\260\351\231\244\346\263\225.md"
index 8c2c3e2d..7f02a963 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer II 001. \346\225\264\346\225\260\351\231\244\346\263\225.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer II 001. \346\225\264\346\225\260\351\231\244\346\263\225.md"
@@ -20,7 +20,7 @@
## 代码
-```Python
+```python
添加备注
diff --git "a/Solutions/\345\211\221\346\214\207 Offer II 002. \344\272\214\350\277\233\345\210\266\345\212\240\346\263\225.md" "b/Solutions/\345\211\221\346\214\207 Offer II 002. \344\272\214\350\277\233\345\210\266\345\212\240\346\263\225.md"
index 762652ce..be1943d5 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer II 002. \344\272\214\350\277\233\345\210\266\345\212\240\346\263\225.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer II 002. \344\272\214\350\277\233\345\210\266\345\212\240\346\263\225.md"
@@ -31,7 +31,7 @@
## 代码
-```Python
+```python
class Solution:
def addBinary(self, a: str, b: str) -> str:
x = int(a, 2)
diff --git "a/Solutions/\345\211\221\346\214\207 Offer II 003. \345\211\215 n \344\270\252\346\225\260\345\255\227\344\272\214\350\277\233\345\210\266\344\270\255 1 \347\232\204\344\270\252\346\225\260.md" "b/Solutions/\345\211\221\346\214\207 Offer II 003. \345\211\215 n \344\270\252\346\225\260\345\255\227\344\272\214\350\277\233\345\210\266\344\270\255 1 \347\232\204\344\270\252\346\225\260.md"
index e3190b62..e7a716e9 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer II 003. \345\211\215 n \344\270\252\346\225\260\345\255\227\344\272\214\350\277\233\345\210\266\344\270\255 1 \347\232\204\344\270\252\346\225\260.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer II 003. \345\211\215 n \344\270\252\346\225\260\345\255\227\344\272\214\350\277\233\345\210\266\344\270\255 1 \347\232\204\344\270\252\346\225\260.md"
@@ -21,7 +21,7 @@
## 代码
-```Python
+```python
class Solution:
def countBits(self, n: int) -> List[int]:
dp = [0 for _ in range(n + 1)]
diff --git "a/Solutions/\345\211\221\346\214\207 Offer II 004. \345\217\252\345\207\272\347\216\260\344\270\200\346\254\241\347\232\204\346\225\260\345\255\227.md" "b/Solutions/\345\211\221\346\214\207 Offer II 004. \345\217\252\345\207\272\347\216\260\344\270\200\346\254\241\347\232\204\346\225\260\345\255\227.md"
index 60b1d8c5..4a2442b7 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer II 004. \345\217\252\345\207\272\347\216\260\344\270\200\346\254\241\347\232\204\346\225\260\345\255\227.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer II 004. \345\217\252\345\207\272\347\216\260\344\270\200\346\254\241\347\232\204\346\225\260\345\255\227.md"
@@ -27,7 +27,7 @@
1. 哈希表
-```Python
+```python
class Solution:
def singleNumber(self, nums: List[int]) -> int:
nums_dict = dict()
@@ -45,7 +45,7 @@ class Solution:
2. 位运算
-```Python
+```python
class Solution:
def singleNumber(self, nums: List[int]) -> int:
ans = 0
diff --git "a/Solutions/\345\211\221\346\214\207 Offer II 005. \345\215\225\350\257\215\351\225\277\345\272\246\347\232\204\346\234\200\345\244\247\344\271\230\347\247\257.md" "b/Solutions/\345\211\221\346\214\207 Offer II 005. \345\215\225\350\257\215\351\225\277\345\272\246\347\232\204\346\234\200\345\244\247\344\271\230\347\247\257.md"
index 5e2d2e6b..c6168049 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer II 005. \345\215\225\350\257\215\351\225\277\345\272\246\347\232\204\346\234\200\345\244\247\344\271\230\347\247\257.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer II 005. \345\215\225\350\257\215\351\225\277\345\272\246\347\232\204\346\234\200\345\244\247\344\271\230\347\247\257.md"
@@ -19,7 +19,7 @@
## 代码
-```Python
+```python
class Solution:
def maxProduct(self, words: List[str]) -> int:
size = len(words)
diff --git "a/Solutions/\345\211\221\346\214\207 Offer II 006. \346\216\222\345\272\217\346\225\260\347\273\204\344\270\255\344\270\244\344\270\252\346\225\260\345\255\227\344\271\213\345\222\214.md" "b/Solutions/\345\211\221\346\214\207 Offer II 006. \346\216\222\345\272\217\346\225\260\347\273\204\344\270\255\344\270\244\344\270\252\346\225\260\345\255\227\344\271\213\345\222\214.md"
index 83392663..bcd7bdbc 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer II 006. \346\216\222\345\272\217\346\225\260\347\273\204\344\270\255\344\270\244\344\270\252\346\225\260\345\255\227\344\271\213\345\222\214.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer II 006. \346\216\222\345\272\217\346\225\260\347\273\204\344\270\255\344\270\244\344\270\252\346\225\260\345\255\227\344\271\213\345\222\214.md"
@@ -15,7 +15,7 @@
## 代码
-```Python
+```python
class Solution:
def twoSum(self, numbers: List[int], target: int) -> List[int]:
low = 0
diff --git "a/Solutions/\345\211\221\346\214\207 Offer II 007. \346\225\260\347\273\204\344\270\255\345\222\214\344\270\272 0 \347\232\204\344\270\211\344\270\252\346\225\260.md" "b/Solutions/\345\211\221\346\214\207 Offer II 007. \346\225\260\347\273\204\344\270\255\345\222\214\344\270\272 0 \347\232\204\344\270\211\344\270\252\346\225\260.md"
index 08354d2c..246c6a13 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer II 007. \346\225\260\347\273\204\344\270\255\345\222\214\344\270\272 0 \347\232\204\344\270\211\344\270\252\346\225\260.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer II 007. \346\225\260\347\273\204\344\270\255\345\222\214\344\270\272 0 \347\232\204\344\270\211\344\270\252\346\225\260.md"
@@ -24,7 +24,7 @@
## 代码
-```Python
+```python
class Solution:
def threeSum(self, nums: List[int]) -> List[List[int]]:
n = len(nums)
diff --git "a/Solutions/\345\211\221\346\214\207 Offer II 008. \345\222\214\345\244\247\344\272\216\347\255\211\344\272\216 target \347\232\204\346\234\200\347\237\255\345\255\220\346\225\260\347\273\204.md" "b/Solutions/\345\211\221\346\214\207 Offer II 008. \345\222\214\345\244\247\344\272\216\347\255\211\344\272\216 target \347\232\204\346\234\200\347\237\255\345\255\220\346\225\260\347\273\204.md"
index 708735ee..1b215e44 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer II 008. \345\222\214\345\244\247\344\272\216\347\255\211\344\272\216 target \347\232\204\346\234\200\347\237\255\345\255\220\346\225\260\347\273\204.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer II 008. \345\222\214\345\244\247\344\272\216\347\255\211\344\272\216 target \347\232\204\346\234\200\347\237\255\345\255\220\346\225\260\347\273\204.md"
@@ -21,7 +21,7 @@
## 代码
-```Python
+```python
class Solution:
def minSubArrayLen(self, target: int, nums: List[int]) -> int:
if not nums:
diff --git "a/Solutions/\345\211\221\346\214\207 Offer II 009. \344\271\230\347\247\257\345\260\217\344\272\216 K \347\232\204\345\255\220\346\225\260\347\273\204.md" "b/Solutions/\345\211\221\346\214\207 Offer II 009. \344\271\230\347\247\257\345\260\217\344\272\216 K \347\232\204\345\255\220\346\225\260\347\273\204.md"
index 36aed665..379b653a 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer II 009. \344\271\230\347\247\257\345\260\217\344\272\216 K \347\232\204\345\255\220\346\225\260\347\273\204.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer II 009. \344\271\230\347\247\257\345\260\217\344\272\216 K \347\232\204\345\255\220\346\225\260\347\273\204.md"
@@ -25,7 +25,7 @@
## 代码
-```Python
+```python
class Solution:
def numSubarrayProductLessThanK(self, nums: List[int], k: int) -> int:
if k <= 1:
diff --git "a/Solutions/\345\211\221\346\214\207 Offer II 010. \345\222\214\344\270\272 k \347\232\204\345\255\220\346\225\260\347\273\204.md" "b/Solutions/\345\211\221\346\214\207 Offer II 010. \345\222\214\344\270\272 k \347\232\204\345\255\220\346\225\260\347\273\204.md"
index e754abf6..89c3be6a 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer II 010. \345\222\214\344\270\272 k \347\232\204\345\255\220\346\225\260\347\273\204.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer II 010. \345\222\214\344\270\272 k \347\232\204\345\255\220\346\225\260\347\273\204.md"
@@ -15,7 +15,7 @@
先考虑暴力做法,外层两重循环,遍历所有连续子数组,然后最内层再计算一下子数组的和。部分代码如下:
-```Python
+```python
for i in range(len(nums)):
for j in range(i + 1):
sum = countSum(i, j)
@@ -44,7 +44,7 @@ for i in range(len(nums)):
## 代码
-```Python
+```python
class Solution:
def subarraySum(self, nums: List[int], k: int) -> int:
pre_dic = {0: 1}
diff --git "a/Solutions/\345\211\221\346\214\207 Offer II 011. 0 \345\222\214 1 \344\270\252\346\225\260\347\233\270\345\220\214\347\232\204\345\255\220\346\225\260\347\273\204.md" "b/Solutions/\345\211\221\346\214\207 Offer II 011. 0 \345\222\214 1 \344\270\252\346\225\260\347\233\270\345\220\214\347\232\204\345\255\220\346\225\260\347\273\204.md"
index f4929c8a..4b6175fc 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer II 011. 0 \345\222\214 1 \344\270\252\346\225\260\347\233\270\345\220\214\347\232\204\345\255\220\346\225\260\347\273\204.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer II 011. 0 \345\222\214 1 \344\270\252\346\225\260\347\233\270\345\220\214\347\232\204\345\255\220\346\225\260\347\273\204.md"
@@ -44,7 +44,7 @@
## 代码
-```Python
+```python
class Solution:
def findMaxLength(self, nums: List[int]) -> int:
pre_dic = {0: -1}
diff --git "a/Solutions/\345\211\221\346\214\207 Offer II 012. \345\267\246\345\217\263\344\270\244\350\276\271\345\255\220\346\225\260\347\273\204\347\232\204\345\222\214\347\233\270\347\255\211.md" "b/Solutions/\345\211\221\346\214\207 Offer II 012. \345\267\246\345\217\263\344\270\244\350\276\271\345\255\220\346\225\260\347\273\204\347\232\204\345\222\214\347\233\270\347\255\211.md"
index 3111b3c3..adb9cced 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer II 012. \345\267\246\345\217\263\344\270\244\350\276\271\345\255\220\346\225\260\347\273\204\347\232\204\345\222\214\347\233\270\347\255\211.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer II 012. \345\267\246\345\217\263\344\270\244\350\276\271\345\255\220\346\225\260\347\273\204\347\232\204\345\222\214\347\233\270\347\255\211.md"
@@ -15,7 +15,7 @@
## 代码
-```Python
+```python
class Solution:
def pivotIndex(self, nums: List[int]) -> int:
sum = 0
diff --git "a/Solutions/\345\211\221\346\214\207 Offer II 013. \344\272\214\347\273\264\345\255\220\347\237\251\351\230\265\347\232\204\345\222\214.md" "b/Solutions/\345\211\221\346\214\207 Offer II 013. \344\272\214\347\273\264\345\255\220\347\237\251\351\230\265\347\232\204\345\222\214.md"
index af526294..7b06570d 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer II 013. \344\272\214\347\273\264\345\255\220\347\237\251\351\230\265\347\232\204\345\222\214.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer II 013. \344\272\214\347\273\264\345\255\220\347\237\251\351\230\265\347\232\204\345\222\214.md"
@@ -22,7 +22,7 @@
## 代码
-```Python
+```python
class NumMatrix:
def __init__(self, matrix: List[List[int]]):
diff --git "a/Solutions/\345\211\221\346\214\207 Offer II 016. \344\270\215\345\220\253\351\207\215\345\244\215\345\255\227\347\254\246\347\232\204\346\234\200\351\225\277\345\255\220\345\255\227\347\254\246\344\270\262.md" "b/Solutions/\345\211\221\346\214\207 Offer II 016. \344\270\215\345\220\253\351\207\215\345\244\215\345\255\227\347\254\246\347\232\204\346\234\200\351\225\277\345\255\220\345\255\227\347\254\246\344\270\262.md"
index 87878f81..58cd1d55 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer II 016. \344\270\215\345\220\253\351\207\215\345\244\215\345\255\227\347\254\246\347\232\204\346\234\200\351\225\277\345\255\220\345\255\227\347\254\246\344\270\262.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer II 016. \344\270\215\345\220\253\351\207\215\345\244\215\345\255\227\347\254\246\347\232\204\346\234\200\351\225\277\345\255\220\345\255\227\347\254\246\344\270\262.md"
@@ -15,7 +15,7 @@
## 代码
-```Python
+```python
class Solution:
def lengthOfLongestSubstring(self, s: str) -> int:
if not s:
diff --git "a/Solutions/\345\211\221\346\214\207 Offer II 017. \345\220\253\346\234\211\346\211\200\346\234\211\345\255\227\347\254\246\347\232\204\346\234\200\347\237\255\345\255\227\347\254\246\344\270\262.md" "b/Solutions/\345\211\221\346\214\207 Offer II 017. \345\220\253\346\234\211\346\211\200\346\234\211\345\255\227\347\254\246\347\232\204\346\234\200\347\237\255\345\255\227\347\254\246\344\270\262.md"
index 671232cd..4f0bfe65 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer II 017. \345\220\253\346\234\211\346\211\200\346\234\211\345\255\227\347\254\246\347\232\204\346\234\200\347\237\255\345\255\227\347\254\246\344\270\262.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer II 017. \345\220\253\346\234\211\346\211\200\346\234\211\345\255\227\347\254\246\347\232\204\346\234\200\347\237\255\345\255\227\347\254\246\344\270\262.md"
@@ -19,7 +19,7 @@
## 代码
-```Python
+```python
class Solution:
def minWindow(self, s: str, t: str) -> str:
need = collections.defaultdict(int)
diff --git "a/Solutions/\345\211\221\346\214\207 Offer II 018. \346\234\211\346\225\210\347\232\204\345\233\236\346\226\207.md" "b/Solutions/\345\211\221\346\214\207 Offer II 018. \346\234\211\346\225\210\347\232\204\345\233\236\346\226\207.md"
index d875f32e..539ce5e2 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer II 018. \346\234\211\346\225\210\347\232\204\345\233\236\346\226\207.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer II 018. \346\234\211\346\225\210\347\232\204\345\233\236\346\226\207.md"
@@ -15,7 +15,7 @@
## 代码
-```Python
+```python
class Solution:
def isPalindrome(self, s: str) -> bool:
n = len(s)
diff --git "a/Solutions/\345\211\221\346\214\207 Offer II 019. \346\234\200\345\244\232\345\210\240\351\231\244\344\270\200\344\270\252\345\255\227\347\254\246\345\276\227\345\210\260\345\233\236\346\226\207.md" "b/Solutions/\345\211\221\346\214\207 Offer II 019. \346\234\200\345\244\232\345\210\240\351\231\244\344\270\200\344\270\252\345\255\227\347\254\246\345\276\227\345\210\260\345\233\236\346\226\207.md"
index e7cf1cab..8f1927bd 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer II 019. \346\234\200\345\244\232\345\210\240\351\231\244\344\270\200\344\270\252\345\255\227\347\254\246\345\276\227\345\210\260\345\233\236\346\226\207.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer II 019. \346\234\200\345\244\232\345\210\240\351\231\244\344\270\200\344\270\252\345\255\227\347\254\246\345\276\227\345\210\260\345\233\236\346\226\207.md"
@@ -26,7 +26,7 @@
## 代码
-```Python
+```python
class Solution:
def checkPalindrome(self, s: str, left: int, right: int):
i, j = left, right
diff --git "a/Solutions/\345\211\221\346\214\207 Offer II 020. \345\233\236\346\226\207\345\255\220\345\255\227\347\254\246\344\270\262\347\232\204\344\270\252\346\225\260.md" "b/Solutions/\345\211\221\346\214\207 Offer II 020. \345\233\236\346\226\207\345\255\220\345\255\227\347\254\246\344\270\262\347\232\204\344\270\252\346\225\260.md"
index 553e5c2a..4bd4a042 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer II 020. \345\233\236\346\226\207\345\255\220\345\255\227\347\254\246\344\270\262\347\232\204\344\270\252\346\225\260.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer II 020. \345\233\236\346\226\207\345\255\220\345\255\227\347\254\246\344\270\262\347\232\204\344\270\252\346\225\260.md"
@@ -33,7 +33,7 @@
## 代码
-```Python
+```python
class Solution:
def countSubstrings(self, s: str) -> int:
size = len(s)
diff --git "a/Solutions/\345\211\221\346\214\207 Offer II 021. \345\210\240\351\231\244\351\223\276\350\241\250\347\232\204\345\200\222\346\225\260\347\254\254 n \344\270\252\347\273\223\347\202\271.md" "b/Solutions/\345\211\221\346\214\207 Offer II 021. \345\210\240\351\231\244\351\223\276\350\241\250\347\232\204\345\200\222\346\225\260\347\254\254 n \344\270\252\347\273\223\347\202\271.md"
index b9d8fa17..b76af31c 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer II 021. \345\210\240\351\231\244\351\223\276\350\241\250\347\232\204\345\200\222\346\225\260\347\254\254 n \344\270\252\347\273\223\347\202\271.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer II 021. \345\210\240\351\231\244\351\223\276\350\241\250\347\232\204\345\200\222\346\225\260\347\254\254 n \344\270\252\347\273\223\347\202\271.md"
@@ -19,7 +19,7 @@
## 代码
-```Python
+```python
class Solution:
def removeNthFromEnd(self, head: ListNode, n: int) -> ListNode:
newHead = ListNode(0, head)
diff --git "a/Solutions/\345\211\221\346\214\207 Offer II 022. \351\223\276\350\241\250\344\270\255\347\216\257\347\232\204\345\205\245\345\217\243\350\212\202\347\202\271.md" "b/Solutions/\345\211\221\346\214\207 Offer II 022. \351\223\276\350\241\250\344\270\255\347\216\257\347\232\204\345\205\245\345\217\243\350\212\202\347\202\271.md"
index fefe7aec..35a1b9a5 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer II 022. \351\223\276\350\241\250\344\270\255\347\216\257\347\232\204\345\205\245\345\217\243\350\212\202\347\202\271.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer II 022. \351\223\276\350\241\250\344\270\255\347\216\257\347\232\204\345\205\245\345\217\243\350\212\202\347\202\271.md"
@@ -23,7 +23,7 @@ $2(a + b) = a + n(b + c) + b$。可以推出:$a = c + (n-1)(b + c)$。
## 代码
-```Python
+```python
class Solution:
def detectCycle(self, head: ListNode) -> ListNode:
fast, slow = head, head
diff --git "a/Solutions/\345\211\221\346\214\207 Offer II 023. \344\270\244\344\270\252\351\223\276\350\241\250\347\232\204\347\254\254\344\270\200\344\270\252\351\207\215\345\220\210\350\212\202\347\202\271.md" "b/Solutions/\345\211\221\346\214\207 Offer II 023. \344\270\244\344\270\252\351\223\276\350\241\250\347\232\204\347\254\254\344\270\200\344\270\252\351\207\215\345\220\210\350\212\202\347\202\271.md"
index 5615329c..95061981 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer II 023. \344\270\244\344\270\252\351\223\276\350\241\250\347\232\204\347\254\254\344\270\200\344\270\252\351\207\215\345\220\210\350\212\202\347\202\271.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer II 023. \344\270\244\344\270\252\351\223\276\350\241\250\347\232\204\347\254\254\344\270\200\344\270\252\351\207\215\345\220\210\350\212\202\347\202\271.md"
@@ -33,7 +33,7 @@
## 代码
-```Python
+```python
class Solution:
def getIntersectionNode(self, headA: ListNode, headB: ListNode) -> ListNode:
if headA == None or headB == None:
diff --git "a/Solutions/\345\211\221\346\214\207 Offer II 024. \345\217\215\350\275\254\351\223\276\350\241\250.md" "b/Solutions/\345\211\221\346\214\207 Offer II 024. \345\217\215\350\275\254\351\223\276\350\241\250.md"
index f7f0a987..95383a8f 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer II 024. \345\217\215\350\275\254\351\223\276\350\241\250.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer II 024. \345\217\215\350\275\254\351\223\276\350\241\250.md"
@@ -47,7 +47,7 @@
1. 迭代
-```Python
+```python
class Solution:
def reverseList(self, head: ListNode) -> ListNode:
pre = None
@@ -62,7 +62,7 @@ class Solution:
2. 递归
-```Python
+```python
class Solution:
def reverseList(self, head: ListNode) -> ListNode:
if head == None or head.next == None:
diff --git "a/Solutions/\345\211\221\346\214\207 Offer II 025. \351\223\276\350\241\250\344\270\255\347\232\204\344\270\244\346\225\260\347\233\270\345\212\240.md" "b/Solutions/\345\211\221\346\214\207 Offer II 025. \351\223\276\350\241\250\344\270\255\347\232\204\344\270\244\346\225\260\347\233\270\345\212\240.md"
index e76e94c6..bcedfeaf 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer II 025. \351\223\276\350\241\250\344\270\255\347\232\204\344\270\244\346\225\260\347\233\270\345\212\240.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer II 025. \351\223\276\350\241\250\344\270\255\347\232\204\344\270\244\346\225\260\347\233\270\345\212\240.md"
@@ -27,7 +27,7 @@
## 代码
-```Python
+```python
class Solution:
def addTwoNumbers(self, l1: ListNode, l2: ListNode) -> ListNode:
stack1, stack2 = [], []
diff --git "a/Solutions/\345\211\221\346\214\207 Offer II 026. \351\207\215\346\216\222\351\223\276\350\241\250.md" "b/Solutions/\345\211\221\346\214\207 Offer II 026. \351\207\215\346\216\222\351\223\276\350\241\250.md"
index 08349608..fe6d08e7 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer II 026. \351\207\215\346\216\222\351\223\276\350\241\250.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer II 026. \351\207\215\346\216\222\351\223\276\350\241\250.md"
@@ -17,7 +17,7 @@
## 代码
-```Python
+```python
class Solution:
def reorderList(self, head: ListNode) -> None:
"""
diff --git "a/Solutions/\345\211\221\346\214\207 Offer II 027. \345\233\236\346\226\207\351\223\276\350\241\250.md" "b/Solutions/\345\211\221\346\214\207 Offer II 027. \345\233\236\346\226\207\351\223\276\350\241\250.md"
index 0a317206..9454ef43 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer II 027. \345\233\236\346\226\207\351\223\276\350\241\250.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer II 027. \345\233\236\346\226\207\351\223\276\350\241\250.md"
@@ -15,7 +15,7 @@
## 代码
-```Python
+```python
class Solution:
def isPalindrome(self, head: ListNode) -> bool:
nodes = []
diff --git "a/Solutions/\345\211\221\346\214\207 Offer II 028. \345\261\225\345\271\263\345\244\232\347\272\247\345\217\214\345\220\221\351\223\276\350\241\250.md" "b/Solutions/\345\211\221\346\214\207 Offer II 028. \345\261\225\345\271\263\345\244\232\347\272\247\345\217\214\345\220\221\351\223\276\350\241\250.md"
index e2e18f63..b29580b1 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer II 028. \345\261\225\345\271\263\345\244\232\347\272\247\345\217\214\345\220\221\351\223\276\350\241\250.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer II 028. \345\261\225\345\271\263\345\244\232\347\272\247\345\217\214\345\220\221\351\223\276\350\241\250.md"
@@ -28,7 +28,7 @@
## 代码
-```Python
+```python
class Solution:
def dfs(self, node: 'Node'):
# 找到链表的尾节点或 child 链表不为空的节点
diff --git "a/Solutions/\345\211\221\346\214\207 Offer II 029. \346\216\222\345\272\217\347\232\204\345\276\252\347\216\257\351\223\276\350\241\250.md" "b/Solutions/\345\211\221\346\214\207 Offer II 029. \346\216\222\345\272\217\347\232\204\345\276\252\347\216\257\351\223\276\350\241\250.md"
index e72ff53e..ea2a7dea 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer II 029. \346\216\222\345\272\217\347\232\204\345\276\252\347\216\257\351\223\276\350\241\250.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer II 029. \346\216\222\345\272\217\347\232\204\345\276\252\347\216\257\351\223\276\350\241\250.md"
@@ -22,7 +22,7 @@
## 代码
-```Python
+```python
class Solution:
def insert(self, head: 'Node', insertVal: int) -> 'Node':
if not head:
diff --git "a/Solutions/\345\211\221\346\214\207 Offer II 030. \346\217\222\345\205\245\343\200\201\345\210\240\351\231\244\345\222\214\351\232\217\346\234\272\350\256\277\351\227\256\351\203\275\346\230\257 O(1) \347\232\204\345\256\271\345\231\250.md" "b/Solutions/\345\211\221\346\214\207 Offer II 030. \346\217\222\345\205\245\343\200\201\345\210\240\351\231\244\345\222\214\351\232\217\346\234\272\350\256\277\351\227\256\351\203\275\346\230\257 O(1) \347\232\204\345\256\271\345\231\250.md"
index b9d412b0..28a9c053 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer II 030. \346\217\222\345\205\245\343\200\201\345\210\240\351\231\244\345\222\214\351\232\217\346\234\272\350\256\277\351\227\256\351\203\275\346\230\257 O(1) \347\232\204\345\256\271\345\231\250.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer II 030. \346\217\222\345\205\245\343\200\201\345\210\240\351\231\244\345\222\214\351\232\217\346\234\272\350\256\277\351\227\256\351\203\275\346\230\257 O(1) \347\232\204\345\256\271\345\231\250.md"
@@ -21,7 +21,7 @@
## 代码
-```Python
+```python
import random
class RandomizedSet:
diff --git "a/Solutions/\345\211\221\346\214\207 Offer II 031. \346\234\200\350\277\221\346\234\200\345\260\221\344\275\277\347\224\250\347\274\223\345\255\230.md" "b/Solutions/\345\211\221\346\214\207 Offer II 031. \346\234\200\350\277\221\346\234\200\345\260\221\344\275\277\347\224\250\347\274\223\345\255\230.md"
index 4a08f146..ee3a8480 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer II 031. \346\234\200\350\277\221\346\234\200\345\260\221\344\275\277\347\224\250\347\274\223\345\255\230.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer II 031. \346\234\200\350\277\221\346\234\200\345\260\221\344\275\277\347\224\250\347\274\223\345\255\230.md"
@@ -19,7 +19,7 @@ LRU(最近最少使用缓存)是一种常用的页面置换算法,选择
## 代码
-```Python
+```python
class Node:
def __init__(self, key=None, val=None, prev=None, next=None):
self.key = key
diff --git "a/Solutions/\345\211\221\346\214\207 Offer II 032. \346\234\211\346\225\210\347\232\204\345\217\230\344\275\215\350\257\215.md" "b/Solutions/\345\211\221\346\214\207 Offer II 032. \346\234\211\346\225\210\347\232\204\345\217\230\344\275\215\350\257\215.md"
index 2cfa7324..7a31073b 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer II 032. \346\234\211\346\225\210\347\232\204\345\217\230\344\275\215\350\257\215.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer II 032. \346\234\211\346\225\210\347\232\204\345\217\230\344\275\215\350\257\215.md"
@@ -19,7 +19,7 @@
## 代码
-```Python
+```python
class Solution:
def isAnagram(self, s: str, t: str) -> bool:
if len(s) != len(t) or s == t:
diff --git "a/Solutions/\345\211\221\346\214\207 Offer II 033. \345\217\230\344\275\215\350\257\215\347\273\204.md" "b/Solutions/\345\211\221\346\214\207 Offer II 033. \345\217\230\344\275\215\350\257\215\347\273\204.md"
index 3048bebd..fe5bc2b9 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer II 033. \345\217\230\344\275\215\350\257\215\347\273\204.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer II 033. \345\217\230\344\275\215\350\257\215\347\273\204.md"
@@ -15,7 +15,7 @@
## 代码
-```Python
+```python
class Solution:
def groupAnagrams(self, strs: List[str]) -> List[List[str]]:
str_dict = dict()
diff --git "a/Solutions/\345\211\221\346\214\207 Offer II 034. \345\244\226\346\230\237\350\257\255\350\250\200\346\230\257\345\220\246\346\216\222\345\272\217.md" "b/Solutions/\345\211\221\346\214\207 Offer II 034. \345\244\226\346\230\237\350\257\255\350\250\200\346\230\257\345\220\246\346\216\222\345\272\217.md"
index ebd00b85..30e11640 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer II 034. \345\244\226\346\230\237\350\257\255\350\250\200\346\230\257\345\220\246\346\216\222\345\272\217.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer II 034. \345\244\226\346\230\237\350\257\255\350\250\200\346\230\257\345\220\246\346\216\222\345\272\217.md"
@@ -19,7 +19,7 @@
## 代码
-```Python
+```python
class Solution:
def isAlienSorted(self, words: List[str], order: str) -> bool:
order_map = dict()
diff --git "a/Solutions/\345\211\221\346\214\207 Offer II 035. \346\234\200\345\260\217\346\227\266\351\227\264\345\267\256.md" "b/Solutions/\345\211\221\346\214\207 Offer II 035. \346\234\200\345\260\217\346\227\266\351\227\264\345\267\256.md"
index a49164a4..733f42d5 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer II 035. \346\234\200\345\260\217\346\227\266\351\227\264\345\267\256.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer II 035. \346\234\200\345\260\217\346\227\266\351\227\264\345\267\256.md"
@@ -18,7 +18,7 @@
## 代码
-```Python
+```python
class Solution:
def changeTime(self, timePoint: str):
hours, minutes = timePoint.split(':')
diff --git "a/Solutions/\345\211\221\346\214\207 Offer II 036. \345\220\216\347\274\200\350\241\250\350\276\276\345\274\217.md" "b/Solutions/\345\211\221\346\214\207 Offer II 036. \345\220\216\347\274\200\350\241\250\350\276\276\345\274\217.md"
index be965f65..d7e9dea8 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer II 036. \345\220\216\347\274\200\350\241\250\350\276\276\345\274\217.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer II 036. \345\220\216\347\274\200\350\241\250\350\276\276\345\274\217.md"
@@ -13,7 +13,7 @@
## 代码
-```Python
+```python
class Solution:
def evalRPN(self, tokens: List[str]) -> int:
stack = []
diff --git "a/Solutions/\345\211\221\346\214\207 Offer II 037. \345\260\217\350\241\214\346\230\237\347\242\260\346\222\236.md" "b/Solutions/\345\211\221\346\214\207 Offer II 037. \345\260\217\350\241\214\346\230\237\347\242\260\346\222\236.md"
index e56ff7aa..a4a2966e 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer II 037. \345\260\217\350\241\214\346\230\237\347\242\260\346\222\236.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer II 037. \345\260\217\350\241\214\346\230\237\347\242\260\346\222\236.md"
@@ -27,7 +27,7 @@
## 代码
-```Python
+```python
class Solution:
def asteroidCollision(self, asteroids: List[int]) -> List[int]:
stack = []
diff --git "a/Solutions/\345\211\221\346\214\207 Offer II 038. \346\257\217\346\227\245\346\270\251\345\272\246.md" "b/Solutions/\345\211\221\346\214\207 Offer II 038. \346\257\217\346\227\245\346\270\251\345\272\246.md"
index eb20764e..9c754a3a 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer II 038. \346\257\217\346\227\245\346\270\251\345\272\246.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer II 038. \346\257\217\346\227\245\346\270\251\345\272\246.md"
@@ -24,7 +24,7 @@
## 代码
-```Python
+```python
class Solution:
def dailyTemperatures(self, temperatures: List[int]) -> List[int]:
n = len(temperatures)
diff --git "a/Solutions/\345\211\221\346\214\207 Offer II 039. \347\233\264\346\226\271\345\233\276\346\234\200\345\244\247\347\237\251\345\275\242\351\235\242\347\247\257.md" "b/Solutions/\345\211\221\346\214\207 Offer II 039. \347\233\264\346\226\271\345\233\276\346\234\200\345\244\247\347\237\251\345\275\242\351\235\242\347\247\257.md"
index 5f40590a..376e7c05 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer II 039. \347\233\264\346\226\271\345\233\276\346\234\200\345\244\247\347\237\251\345\275\242\351\235\242\347\247\257.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer II 039. \347\233\264\346\226\271\345\233\276\346\234\200\345\244\247\347\237\251\345\275\242\351\235\242\347\247\257.md"
@@ -26,7 +26,7 @@
## 代码
-```Python
+```python
class Solution:
def largestRectangleArea(self, heights: List[int]) -> int:
heights.append(0)
diff --git "a/Solutions/\345\211\221\346\214\207 Offer II 041. \346\273\221\345\212\250\347\252\227\345\217\243\347\232\204\345\271\263\345\235\207\345\200\274.md" "b/Solutions/\345\211\221\346\214\207 Offer II 041. \346\273\221\345\212\250\347\252\227\345\217\243\347\232\204\345\271\263\345\235\207\345\200\274.md"
index 1c6575c2..27487565 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer II 041. \346\273\221\345\212\250\347\252\227\345\217\243\347\232\204\345\271\263\345\235\207\345\200\274.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer II 041. \346\273\221\345\212\250\347\252\227\345\217\243\347\232\204\345\271\263\345\235\207\345\200\274.md"
@@ -22,7 +22,7 @@
- 示例 1:
-```Python
+```python
输入:
inputs = ["MovingAverage", "next", "next", "next", "next"]
inputs = [[3], [1], [10], [3], [5]]
@@ -48,7 +48,7 @@ movingAverage.next(5); // 返回 6.0 = (10 + 3 + 5) / 3
### 思路 1:代码
-```Python
+```python
class MovingAverage:
def __init__(self, size: int):
diff --git "a/Solutions/\345\211\221\346\214\207 Offer II 042. \346\234\200\350\277\221\350\257\267\346\261\202\346\254\241\346\225\260.md" "b/Solutions/\345\211\221\346\214\207 Offer II 042. \346\234\200\350\277\221\350\257\267\346\261\202\346\254\241\346\225\260.md"
index 540af209..8f114bd4 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer II 042. \346\234\200\350\277\221\350\257\267\346\261\202\346\254\241\346\225\260.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer II 042. \346\234\200\350\277\221\350\257\267\346\261\202\346\254\241\346\225\260.md"
@@ -18,7 +18,7 @@
## 代码
-```Python
+```python
class RecentCounter:
def __init__(self):
diff --git "a/Solutions/\345\211\221\346\214\207 Offer II 043. \345\276\200\345\256\214\345\205\250\344\272\214\345\217\211\346\240\221\346\267\273\345\212\240\350\212\202\347\202\271.md" "b/Solutions/\345\211\221\346\214\207 Offer II 043. \345\276\200\345\256\214\345\205\250\344\272\214\345\217\211\346\240\221\346\267\273\345\212\240\350\212\202\347\202\271.md"
index 1ea59d38..b20bec27 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer II 043. \345\276\200\345\256\214\345\205\250\344\272\214\345\217\211\346\240\221\346\267\273\345\212\240\350\212\202\347\202\271.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer II 043. \345\276\200\345\256\214\345\205\250\344\272\214\345\217\211\346\240\221\346\267\273\345\212\240\350\212\202\347\202\271.md"
@@ -19,7 +19,7 @@
## 代码
-```Python
+```python
class CBTInserter:
def __init__(self, root: TreeNode):
diff --git "a/Solutions/\345\211\221\346\214\207 Offer II 044. \344\272\214\345\217\211\346\240\221\346\257\217\345\261\202\347\232\204\346\234\200\345\244\247\345\200\274.md" "b/Solutions/\345\211\221\346\214\207 Offer II 044. \344\272\214\345\217\211\346\240\221\346\257\217\345\261\202\347\232\204\346\234\200\345\244\247\345\200\274.md"
index 59d82c38..4a650447 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer II 044. \344\272\214\345\217\211\346\240\221\346\257\217\345\261\202\347\232\204\346\234\200\345\244\247\345\200\274.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer II 044. \344\272\214\345\217\211\346\240\221\346\257\217\345\261\202\347\232\204\346\234\200\345\244\247\345\200\274.md"
@@ -15,7 +15,7 @@
## 代码
-```Python
+```python
class Solution:
def largestValues(self, root: TreeNode) -> List[int]:
queue = []
diff --git "a/Solutions/\345\211\221\346\214\207 Offer II 045. \344\272\214\345\217\211\346\240\221\346\234\200\345\272\225\345\261\202\346\234\200\345\267\246\350\276\271\347\232\204\345\200\274.md" "b/Solutions/\345\211\221\346\214\207 Offer II 045. \344\272\214\345\217\211\346\240\221\346\234\200\345\272\225\345\261\202\346\234\200\345\267\246\350\276\271\347\232\204\345\200\274.md"
index 43a4f390..1009a128 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer II 045. \344\272\214\345\217\211\346\240\221\346\234\200\345\272\225\345\261\202\346\234\200\345\267\246\350\276\271\347\232\204\345\200\274.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer II 045. \344\272\214\345\217\211\346\240\221\346\234\200\345\272\225\345\261\202\346\234\200\345\267\246\350\276\271\347\232\204\345\200\274.md"
@@ -19,7 +19,7 @@
## 代码
-```Python
+```python
import collections
class Solution:
diff --git "a/Solutions/\345\211\221\346\214\207 Offer II 046. \344\272\214\345\217\211\346\240\221\347\232\204\345\217\263\344\276\247\350\247\206\345\233\276.md" "b/Solutions/\345\211\221\346\214\207 Offer II 046. \344\272\214\345\217\211\346\240\221\347\232\204\345\217\263\344\276\247\350\247\206\345\233\276.md"
index ce2205f9..cdb1d950 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer II 046. \344\272\214\345\217\211\346\240\221\347\232\204\345\217\263\344\276\247\350\247\206\345\233\276.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer II 046. \344\272\214\345\217\211\346\240\221\347\232\204\345\217\263\344\276\247\350\247\206\345\233\276.md"
@@ -15,7 +15,7 @@
## 代码
-```Python
+```python
class Solution:
def rightSideView(self, root: TreeNode) -> List[int]:
if not root:
diff --git "a/Solutions/\345\211\221\346\214\207 Offer II 047. \344\272\214\345\217\211\346\240\221\345\211\252\346\236\235.md" "b/Solutions/\345\211\221\346\214\207 Offer II 047. \344\272\214\345\217\211\346\240\221\345\211\252\346\236\235.md"
index 7162b7c6..2b08f5d3 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer II 047. \344\272\214\345\217\211\346\240\221\345\211\252\346\236\235.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer II 047. \344\272\214\345\217\211\346\240\221\345\211\252\346\236\235.md"
@@ -21,7 +21,7 @@
## 代码
-```Python
+```python
class Solution:
def containsOnlyZero(self, root: TreeNode):
if not root:
diff --git "a/Solutions/\345\211\221\346\214\207 Offer II 048. \345\272\217\345\210\227\345\214\226\344\270\216\345\217\215\345\272\217\345\210\227\345\214\226\344\272\214\345\217\211\346\240\221.md" "b/Solutions/\345\211\221\346\214\207 Offer II 048. \345\272\217\345\210\227\345\214\226\344\270\216\345\217\215\345\272\217\345\210\227\345\214\226\344\272\214\345\217\211\346\240\221.md"
index 9396a5b9..34b6e031 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer II 048. \345\272\217\345\210\227\345\214\226\344\270\216\345\217\215\345\272\217\345\210\227\345\214\226\344\272\214\345\217\211\346\240\221.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer II 048. \345\272\217\345\210\227\345\214\226\344\270\216\345\217\215\345\272\217\345\210\227\345\214\226\344\272\214\345\217\211\346\240\221.md"
@@ -26,7 +26,7 @@
## 代码
-```Python
+```python
class Codec:
def serialize(self, root):
diff --git "a/Solutions/\345\211\221\346\214\207 Offer II 049. \344\273\216\346\240\271\350\212\202\347\202\271\345\210\260\345\217\266\350\212\202\347\202\271\347\232\204\350\267\257\345\276\204\346\225\260\345\255\227\344\271\213\345\222\214.md" "b/Solutions/\345\211\221\346\214\207 Offer II 049. \344\273\216\346\240\271\350\212\202\347\202\271\345\210\260\345\217\266\350\212\202\347\202\271\347\232\204\350\267\257\345\276\204\346\225\260\345\255\227\344\271\213\345\222\214.md"
index fd021e2a..080a965c 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer II 049. \344\273\216\346\240\271\350\212\202\347\202\271\345\210\260\345\217\266\350\212\202\347\202\271\347\232\204\350\267\257\345\276\204\346\225\260\345\255\227\344\271\213\345\222\214.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer II 049. \344\273\216\346\240\271\350\212\202\347\202\271\345\210\260\345\217\266\350\212\202\347\202\271\347\232\204\350\267\257\345\276\204\346\225\260\345\255\227\344\271\213\345\222\214.md"
@@ -15,7 +15,7 @@
## 代码
-```Python
+```python
class Solution:
def dfs(self, root, pretotal):
if not root:
diff --git "a/Solutions/\345\211\221\346\214\207 Offer II 050. \345\220\221\344\270\213\347\232\204\350\267\257\345\276\204\350\212\202\347\202\271\344\271\213\345\222\214.md" "b/Solutions/\345\211\221\346\214\207 Offer II 050. \345\220\221\344\270\213\347\232\204\350\267\257\345\276\204\350\212\202\347\202\271\344\271\213\345\222\214.md"
index b642e120..e096af7c 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer II 050. \345\220\221\344\270\213\347\232\204\350\267\257\345\276\204\350\212\202\347\202\271\344\271\213\345\222\214.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer II 050. \345\220\221\344\270\213\347\232\204\350\267\257\345\276\204\350\212\202\347\202\271\344\271\213\345\222\214.md"
@@ -13,7 +13,7 @@
## 代码
-```Python
+```python
class Solution:
prefixsum_count = dict()
def dfs(self, root, prefixsum_count, target_sum, cur_sum):
diff --git "a/Solutions/\345\211\221\346\214\207 Offer II 051. \350\212\202\347\202\271\344\271\213\345\222\214\346\234\200\345\244\247\347\232\204\350\267\257\345\276\204.md" "b/Solutions/\345\211\221\346\214\207 Offer II 051. \350\212\202\347\202\271\344\271\213\345\222\214\346\234\200\345\244\247\347\232\204\350\267\257\345\276\204.md"
index 72c10354..d8d288d4 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer II 051. \350\212\202\347\202\271\344\271\213\345\222\214\346\234\200\345\244\247\347\232\204\350\267\257\345\276\204.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer II 051. \350\212\202\347\202\271\344\271\213\345\222\214\346\234\200\345\244\247\347\232\204\350\267\257\345\276\204.md"
@@ -28,7 +28,7 @@
## 代码
-```Python
+```python
class Solution:
def __init__(self):
self.max_sum = float('-inf')
diff --git "a/Solutions/\345\211\221\346\214\207 Offer II 052. \345\261\225\345\271\263\344\272\214\345\217\211\346\220\234\347\264\242\346\240\221.md" "b/Solutions/\345\211\221\346\214\207 Offer II 052. \345\261\225\345\271\263\344\272\214\345\217\211\346\220\234\347\264\242\346\240\221.md"
index bbbc203b..6a5f9463 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer II 052. \345\261\225\345\271\263\344\272\214\345\217\211\346\220\234\347\264\242\346\240\221.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer II 052. \345\261\225\345\271\263\344\272\214\345\217\211\346\220\234\347\264\242\346\240\221.md"
@@ -24,7 +24,7 @@
## 代码
-```Python
+```python
class Solution:
def inOrder(self, root, res):
if not root:
diff --git "a/Solutions/\345\211\221\346\214\207 Offer II 053. \344\272\214\345\217\211\346\220\234\347\264\242\346\240\221\344\270\255\347\232\204\344\270\255\345\272\217\345\220\216\347\273\247.md" "b/Solutions/\345\211\221\346\214\207 Offer II 053. \344\272\214\345\217\211\346\220\234\347\264\242\346\240\221\344\270\255\347\232\204\344\270\255\345\272\217\345\220\216\347\273\247.md"
index 0d79e30a..782ebff3 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer II 053. \344\272\214\345\217\211\346\220\234\347\264\242\346\240\221\344\270\255\347\232\204\344\270\255\345\272\217\345\220\216\347\273\247.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer II 053. \344\272\214\345\217\211\346\220\234\347\264\242\346\240\221\344\270\255\347\232\204\344\270\255\345\272\217\345\220\216\347\273\247.md"
@@ -18,7 +18,7 @@
## 代码
-```Python
+```python
class Solution:
def inorderSuccessor(self, root: 'TreeNode', p: 'TreeNode') -> 'TreeNode':
if not p or not root:
diff --git "a/Solutions/\345\211\221\346\214\207 Offer II 054. \346\211\200\346\234\211\345\244\247\344\272\216\347\255\211\344\272\216\350\212\202\347\202\271\347\232\204\345\200\274\344\271\213\345\222\214.md" "b/Solutions/\345\211\221\346\214\207 Offer II 054. \346\211\200\346\234\211\345\244\247\344\272\216\347\255\211\344\272\216\350\212\202\347\202\271\347\232\204\345\200\274\344\271\213\345\222\214.md"
index 60187189..2883ec05 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer II 054. \346\211\200\346\234\211\345\244\247\344\272\216\347\255\211\344\272\216\350\212\202\347\202\271\347\232\204\345\200\274\344\271\213\345\222\214.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer II 054. \346\211\200\346\234\211\345\244\247\344\272\216\347\255\211\344\272\216\350\212\202\347\202\271\347\232\204\345\200\274\344\271\213\345\222\214.md"
@@ -25,7 +25,7 @@
## 代码
-```Python
+```python
class Solution:
pre = 0
diff --git "a/Solutions/\345\211\221\346\214\207 Offer II 055. \344\272\214\345\217\211\346\220\234\347\264\242\346\240\221\350\277\255\344\273\243\345\231\250.md" "b/Solutions/\345\211\221\346\214\207 Offer II 055. \344\272\214\345\217\211\346\220\234\347\264\242\346\240\221\350\277\255\344\273\243\345\231\250.md"
index 81a03903..0b856bb0 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer II 055. \344\272\214\345\217\211\346\220\234\347\264\242\346\240\221\350\277\255\344\273\243\345\231\250.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer II 055. \344\272\214\345\217\211\346\220\234\347\264\242\346\240\221\350\277\255\344\273\243\345\231\250.md"
@@ -21,7 +21,7 @@
## 代码
-```Python
+```python
class BSTIterator:
def __init__(self, root: TreeNode):
diff --git "a/Solutions/\345\211\221\346\214\207 Offer II 056. \344\272\214\345\217\211\346\220\234\347\264\242\346\240\221\344\270\255\344\270\244\344\270\252\350\212\202\347\202\271\344\271\213\345\222\214.md" "b/Solutions/\345\211\221\346\214\207 Offer II 056. \344\272\214\345\217\211\346\220\234\347\264\242\346\240\221\344\270\255\344\270\244\344\270\252\350\212\202\347\202\271\344\271\213\345\222\214.md"
index 429bed25..7c479a45 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer II 056. \344\272\214\345\217\211\346\220\234\347\264\242\346\240\221\344\270\255\344\270\244\344\270\252\350\212\202\347\202\271\344\271\213\345\222\214.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer II 056. \344\272\214\345\217\211\346\220\234\347\264\242\346\240\221\344\270\255\344\270\244\344\270\252\350\212\202\347\202\271\344\271\213\345\222\214.md"
@@ -15,7 +15,7 @@
## 代码
-```Python
+```python
class Solution:
def inOrder(self, root, nums):
if not root:
diff --git "a/Solutions/\345\211\221\346\214\207 Offer II 057. \345\200\274\345\222\214\344\270\213\346\240\207\344\271\213\345\267\256\351\203\275\345\234\250\347\273\231\345\256\232\347\232\204\350\214\203\345\233\264\345\206\205.md" "b/Solutions/\345\211\221\346\214\207 Offer II 057. \345\200\274\345\222\214\344\270\213\346\240\207\344\271\213\345\267\256\351\203\275\345\234\250\347\273\231\345\256\232\347\232\204\350\214\203\345\233\264\345\206\205.md"
index 5e1628ed..fe3dc161 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer II 057. \345\200\274\345\222\214\344\270\213\346\240\207\344\271\213\345\267\256\351\203\275\345\234\250\347\273\231\345\256\232\347\232\204\350\214\203\345\233\264\345\206\205.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer II 057. \345\200\274\345\222\214\344\270\213\346\240\207\344\271\213\345\267\256\351\203\275\345\234\250\347\273\231\345\256\232\347\232\204\350\214\203\345\233\264\345\206\205.md"
@@ -24,7 +24,7 @@
## 代码
-```Python
+```python
class Solution:
def containsNearbyAlmostDuplicate(self, nums: List[int], k: int, t: int) -> bool:
bucket_dict = dict()
diff --git "a/Solutions/\345\211\221\346\214\207 Offer II 059. \346\225\260\346\215\256\346\265\201\347\232\204\347\254\254 K \345\244\247\346\225\260\345\200\274.md" "b/Solutions/\345\211\221\346\214\207 Offer II 059. \346\225\260\346\215\256\346\265\201\347\232\204\347\254\254 K \345\244\247\346\225\260\345\200\274.md"
index 079905ec..c731407e 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer II 059. \346\225\260\346\215\256\346\265\201\347\232\204\347\254\254 K \345\244\247\346\225\260\345\200\274.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer II 059. \346\225\260\346\215\256\346\265\201\347\232\204\347\254\254 K \345\244\247\346\225\260\345\200\274.md"
@@ -18,7 +18,7 @@
## 代码
-```Python
+```python
import heapq
class KthLargest:
diff --git "a/Solutions/\345\211\221\346\214\207 Offer II 060. \345\207\272\347\216\260\351\242\221\347\216\207\346\234\200\351\253\230\347\232\204 k \344\270\252\346\225\260\345\255\227.md" "b/Solutions/\345\211\221\346\214\207 Offer II 060. \345\207\272\347\216\260\351\242\221\347\216\207\346\234\200\351\253\230\347\232\204 k \344\270\252\346\225\260\345\255\227.md"
index 335050e7..0385ad06 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer II 060. \345\207\272\347\216\260\351\242\221\347\216\207\346\234\200\351\253\230\347\232\204 k \344\270\252\346\225\260\345\255\227.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer II 060. \345\207\272\347\216\260\351\242\221\347\216\207\346\234\200\351\253\230\347\232\204 k \344\270\252\346\225\260\345\255\227.md"
@@ -25,7 +25,7 @@
## 代码
-```Python
+```python
class Solution:
# 调整为大顶堆
def heapify(self, nums, nums_dict, index, end):
diff --git "a/Solutions/\345\211\221\346\214\207 Offer II 062. \345\256\236\347\216\260\345\211\215\347\274\200\346\240\221.md" "b/Solutions/\345\211\221\346\214\207 Offer II 062. \345\256\236\347\216\260\345\211\215\347\274\200\346\240\221.md"
index 4058dea0..0c6eb457 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer II 062. \345\256\236\347\216\260\345\211\215\347\274\200\346\240\221.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer II 062. \345\256\236\347\216\260\345\211\215\347\274\200\346\240\221.md"
@@ -36,7 +36,7 @@
## 代码
-```Python
+```python
class Trie:
def __init__(self):
diff --git "a/Solutions/\345\211\221\346\214\207 Offer II 063. \346\233\277\346\215\242\345\215\225\350\257\215.md" "b/Solutions/\345\211\221\346\214\207 Offer II 063. \346\233\277\346\215\242\345\215\225\350\257\215.md"
index d3050c9a..5657f6cb 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer II 063. \346\233\277\346\215\242\345\215\225\350\257\215.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer II 063. \346\233\277\346\215\242\345\215\225\350\257\215.md"
@@ -15,7 +15,7 @@
## 代码
-```Python
+```python
class Trie:
def __init__(self):
diff --git "a/Solutions/\345\211\221\346\214\207 Offer II 064. \347\245\236\345\245\207\347\232\204\345\255\227\345\205\270.md" "b/Solutions/\345\211\221\346\214\207 Offer II 064. \347\245\236\345\245\207\347\232\204\345\255\227\345\205\270.md"
index b44a07cf..05695991 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer II 064. \347\245\236\345\245\207\347\232\204\345\255\227\345\205\270.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer II 064. \347\245\236\345\245\207\347\232\204\345\255\227\345\205\270.md"
@@ -23,7 +23,7 @@
## 代码
-```Python
+```python
class Trie:
def __init__(self):
diff --git "a/Solutions/\345\211\221\346\214\207 Offer II 065. \346\234\200\347\237\255\347\232\204\345\215\225\350\257\215\347\274\226\347\240\201.md" "b/Solutions/\345\211\221\346\214\207 Offer II 065. \346\234\200\347\237\255\347\232\204\345\215\225\350\257\215\347\274\226\347\240\201.md"
index 0b4a026b..614ba522 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer II 065. \346\234\200\347\237\255\347\232\204\345\215\225\350\257\215\347\274\226\347\240\201.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer II 065. \346\234\200\347\237\255\347\232\204\345\215\225\350\257\215\347\274\226\347\240\201.md"
@@ -19,7 +19,7 @@
## 代码
-```Python
+```python
class Trie:
def __init__(self):
diff --git "a/Solutions/\345\211\221\346\214\207 Offer II 066. \345\215\225\350\257\215\344\271\213\345\222\214.md" "b/Solutions/\345\211\221\346\214\207 Offer II 066. \345\215\225\350\257\215\344\271\213\345\222\214.md"
index edf40eef..9692e7f2 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer II 066. \345\215\225\350\257\215\344\271\213\345\222\214.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer II 066. \345\215\225\350\257\215\344\271\213\345\222\214.md"
@@ -22,7 +22,7 @@
## 代码
-```Python
+```python
class Trie:
def __init__(self):
diff --git "a/Solutions/\345\211\221\346\214\207 Offer II 067. \346\234\200\345\244\247\347\232\204\345\274\202\346\210\226.md" "b/Solutions/\345\211\221\346\214\207 Offer II 067. \346\234\200\345\244\247\347\232\204\345\274\202\346\210\226.md"
index 3a12e250..0f40000f 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer II 067. \346\234\200\345\244\247\347\232\204\345\274\202\346\210\226.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer II 067. \346\234\200\345\244\247\347\232\204\345\274\202\346\210\226.md"
@@ -21,7 +21,7 @@
## 代码
-```Python
+```python
class Trie:
def __init__(self):
diff --git "a/Solutions/\345\211\221\346\214\207 Offer II 068. \346\237\245\346\211\276\346\217\222\345\205\245\344\275\215\347\275\256.md" "b/Solutions/\345\211\221\346\214\207 Offer II 068. \346\237\245\346\211\276\346\217\222\345\205\245\344\275\215\347\275\256.md"
index 59136363..d35d5241 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer II 068. \346\237\245\346\211\276\346\217\222\345\205\245\344\275\215\347\275\256.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer II 068. \346\237\245\346\211\276\346\217\222\345\205\245\344\275\215\347\275\256.md"
@@ -15,7 +15,7 @@
## 代码
-```Python
+```python
class Solution:
def searchInsert(self, nums: List[int], target: int) -> int:
n = len(nums)
diff --git "a/Solutions/\345\211\221\346\214\207 Offer II 072. \346\261\202\345\271\263\346\226\271\346\240\271.md" "b/Solutions/\345\211\221\346\214\207 Offer II 072. \346\261\202\345\271\263\346\226\271\346\240\271.md"
index f91eaed4..7bf46d4e 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer II 072. \346\261\202\345\271\263\346\226\271\346\240\271.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer II 072. \346\261\202\345\271\263\346\226\271\346\240\271.md"
@@ -15,7 +15,7 @@
## 代码
-```Python
+```python
class Solution:
def mySqrt(self, x: int) -> int:
left = 0
diff --git "a/Solutions/\345\211\221\346\214\207 Offer II 073. \347\213\222\347\213\222\345\220\203\351\246\231\350\225\211.md" "b/Solutions/\345\211\221\346\214\207 Offer II 073. \347\213\222\347\213\222\345\220\203\351\246\231\350\225\211.md"
index 6f661751..e3dc5c44 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer II 073. \347\213\222\347\213\222\345\220\203\351\246\231\350\225\211.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer II 073. \347\213\222\347\213\222\345\220\203\351\246\231\350\225\211.md"
@@ -24,7 +24,7 @@
## 代码
-```Python
+```python
class Solution:
def canEat(self, piles, hour, speed):
time = 0
diff --git "a/Solutions/\345\211\221\346\214\207 Offer II 074. \345\220\210\345\271\266\345\214\272\351\227\264.md" "b/Solutions/\345\211\221\346\214\207 Offer II 074. \345\220\210\345\271\266\345\214\272\351\227\264.md"
index 59f670d3..a3b62427 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer II 074. \345\220\210\345\271\266\345\214\272\351\227\264.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer II 074. \345\220\210\345\271\266\345\214\272\351\227\264.md"
@@ -17,7 +17,7 @@
## 代码
-```Python
+```python
class Solution:
def merge(self, intervals: List[List[int]]) -> List[List[int]]:
intervals.sort(key=lambda x: x[0])
diff --git "a/Solutions/\345\211\221\346\214\207 Offer II 075. \346\225\260\347\273\204\347\233\270\345\257\271\346\216\222\345\272\217.md" "b/Solutions/\345\211\221\346\214\207 Offer II 075. \346\225\260\347\273\204\347\233\270\345\257\271\346\216\222\345\272\217.md"
index 17fb7ae4..9c49cbc5 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer II 075. \346\225\260\347\273\204\347\233\270\345\257\271\346\216\222\345\272\217.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer II 075. \346\225\260\347\273\204\347\233\270\345\257\271\346\216\222\345\272\217.md"
@@ -26,7 +26,7 @@
## 代码
-```Python
+```python
class Solution:
def relativeSortArray(self, arr1: List[int], arr2: List[int]) -> List[int]:
count = [0 for _ in range(1010)]
diff --git "a/Solutions/\345\211\221\346\214\207 Offer II 076. \346\225\260\347\273\204\344\270\255\347\232\204\347\254\254 k \345\244\247\347\232\204\346\225\260\345\255\227.md" "b/Solutions/\345\211\221\346\214\207 Offer II 076. \346\225\260\347\273\204\344\270\255\347\232\204\347\254\254 k \345\244\247\347\232\204\346\225\260\345\255\227.md"
index 60b68748..a3a569a0 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer II 076. \346\225\260\347\273\204\344\270\255\347\232\204\347\254\254 k \345\244\247\347\232\204\346\225\260\345\255\227.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer II 076. \346\225\260\347\273\204\344\270\255\347\232\204\347\254\254 k \345\244\247\347\232\204\346\225\260\345\255\227.md"
@@ -50,7 +50,7 @@
1. 堆排序
-```Python
+```python
class Solution:
def findKthLargest(self, nums: List[int], k: int) -> int:
# 调整为大顶堆
@@ -91,7 +91,7 @@ class Solution:
2. 快速排序
-```Python
+```python
import random
class Solution:
def findKthLargest(self, nums: List[int], k: int) -> int:
@@ -128,14 +128,14 @@ class Solution:
3. 借用标准库
-```Python
+```python
class Solution:
def findKthLargest(self, nums: List[int], k: int) -> int:
nums.sort()
return nums[len(nums)-k]
```
-```Python
+```python
import heapq
class Solution:
def findKthLargest(self, nums: List[int], k: int) -> int:
diff --git "a/Solutions/\345\211\221\346\214\207 Offer II 077. \351\223\276\350\241\250\346\216\222\345\272\217.md" "b/Solutions/\345\211\221\346\214\207 Offer II 077. \351\223\276\350\241\250\346\216\222\345\272\217.md"
index 954c055c..f8828fe0 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer II 077. \351\223\276\350\241\250\346\216\222\345\272\217.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer II 077. \351\223\276\350\241\250\346\216\222\345\272\217.md"
@@ -19,7 +19,7 @@
## 代码
-```Python
+```python
class Solution:
def merge_sort(self, head: ListNode, tail: ListNode) -> ListNode:
if not head:
diff --git "a/Solutions/\345\211\221\346\214\207 Offer II 078. \345\220\210\345\271\266\346\216\222\345\272\217\351\223\276\350\241\250.md" "b/Solutions/\345\211\221\346\214\207 Offer II 078. \345\220\210\345\271\266\346\216\222\345\272\217\351\223\276\350\241\250.md"
index f56f5a03..d03143f7 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer II 078. \345\220\210\345\271\266\346\216\222\345\272\217\351\223\276\350\241\250.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer II 078. \345\220\210\345\271\266\346\216\222\345\272\217\351\223\276\350\241\250.md"
@@ -15,7 +15,7 @@
## 代码
-```Python
+```python
class Solution:
def merge_sort(self, lists: List[ListNode], left: int, right: int) -> ListNode:
if left == right:
diff --git "a/Solutions/\345\211\221\346\214\207 Offer II 079. \346\211\200\346\234\211\345\255\220\351\233\206.md" "b/Solutions/\345\211\221\346\214\207 Offer II 079. \346\211\200\346\234\211\345\255\220\351\233\206.md"
index 9c4f8e21..e6cecce6 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer II 079. \346\211\200\346\234\211\345\255\220\351\233\206.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer II 079. \346\211\200\346\234\211\345\255\220\351\233\206.md"
@@ -15,7 +15,7 @@
## 代码
-```Python
+```python
class Solution:
def subsets(self, nums: List[int]) -> List[List[int]]:
def backtrack(size, subset, index):
diff --git "a/Solutions/\345\211\221\346\214\207 Offer II 080. \345\220\253\346\234\211 k \344\270\252\345\205\203\347\264\240\347\232\204\347\273\204\345\220\210.md" "b/Solutions/\345\211\221\346\214\207 Offer II 080. \345\220\253\346\234\211 k \344\270\252\345\205\203\347\264\240\347\232\204\347\273\204\345\220\210.md"
index f646fc67..24a231c8 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer II 080. \345\220\253\346\234\211 k \344\270\252\345\205\203\347\264\240\347\232\204\347\273\204\345\220\210.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer II 080. \345\220\253\346\234\211 k \344\270\252\345\205\203\347\264\240\347\232\204\347\273\204\345\220\210.md"
@@ -24,7 +24,7 @@
## 代码
-```Python
+```python
class Solution:
res = []
path = []
diff --git "a/Solutions/\345\211\221\346\214\207 Offer II 081. \345\205\201\350\256\270\351\207\215\345\244\215\351\200\211\346\213\251\345\205\203\347\264\240\347\232\204\347\273\204\345\220\210.md" "b/Solutions/\345\211\221\346\214\207 Offer II 081. \345\205\201\350\256\270\351\207\215\345\244\215\351\200\211\346\213\251\345\205\203\347\264\240\347\232\204\347\273\204\345\220\210.md"
index fb8a4606..3d063b8d 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer II 081. \345\205\201\350\256\270\351\207\215\345\244\215\351\200\211\346\213\251\345\205\203\347\264\240\347\232\204\347\273\204\345\220\210.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer II 081. \345\205\201\350\256\270\351\207\215\345\244\215\351\200\211\346\213\251\345\205\203\347\264\240\347\232\204\347\273\204\345\220\210.md"
@@ -30,7 +30,7 @@
## 代码
-```Python
+```python
class Solution:
res = []
path = []
diff --git "a/Solutions/\345\211\221\346\214\207 Offer II 082. \345\220\253\346\234\211\351\207\215\345\244\215\345\205\203\347\264\240\351\233\206\345\220\210\347\232\204\347\273\204\345\220\210.md" "b/Solutions/\345\211\221\346\214\207 Offer II 082. \345\220\253\346\234\211\351\207\215\345\244\215\345\205\203\347\264\240\351\233\206\345\220\210\347\232\204\347\273\204\345\220\210.md"
index efb56904..1b6661de 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer II 082. \345\220\253\346\234\211\351\207\215\345\244\215\345\205\203\347\264\240\351\233\206\345\220\210\347\232\204\347\273\204\345\220\210.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer II 082. \345\220\253\346\234\211\351\207\215\345\244\215\345\205\203\347\264\240\351\233\206\345\220\210\347\232\204\347\273\204\345\220\210.md"
@@ -19,7 +19,7 @@
## 代码
-```Python
+```python
class Solution:
res = []
path = []
diff --git "a/Solutions/\345\211\221\346\214\207 Offer II 083. \346\262\241\346\234\211\351\207\215\345\244\215\345\205\203\347\264\240\351\233\206\345\220\210\347\232\204\345\205\250\346\216\222\345\210\227.md" "b/Solutions/\345\211\221\346\214\207 Offer II 083. \346\262\241\346\234\211\351\207\215\345\244\215\345\205\203\347\264\240\351\233\206\345\220\210\347\232\204\345\205\250\346\216\222\345\210\227.md"
index ec6f5f0b..a327b471 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer II 083. \346\262\241\346\234\211\351\207\215\345\244\215\345\205\203\347\264\240\351\233\206\345\220\210\347\232\204\345\205\250\346\216\222\345\210\227.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer II 083. \346\262\241\346\234\211\351\207\215\345\244\215\345\205\203\347\264\240\351\233\206\345\220\210\347\232\204\345\205\250\346\216\222\345\210\227.md"
@@ -15,7 +15,7 @@
## 代码
-```Python
+```python
class Solution:
def permute(self, nums: List[int]) -> List[List[int]]:
def backtrack(size, arrange, index):
diff --git "a/Solutions/\345\211\221\346\214\207 Offer II 084. \345\220\253\346\234\211\351\207\215\345\244\215\345\205\203\347\264\240\351\233\206\345\220\210\347\232\204\345\205\250\346\216\222\345\210\227.md" "b/Solutions/\345\211\221\346\214\207 Offer II 084. \345\220\253\346\234\211\351\207\215\345\244\215\345\205\203\347\264\240\351\233\206\345\220\210\347\232\204\345\205\250\346\216\222\345\210\227.md"
index 1fa9167e..502c02e5 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer II 084. \345\220\253\346\234\211\351\207\215\345\244\215\345\205\203\347\264\240\351\233\206\345\220\210\347\232\204\345\205\250\346\216\222\345\210\227.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer II 084. \345\220\253\346\234\211\351\207\215\345\244\215\345\205\203\347\264\240\351\233\206\345\220\210\347\232\204\345\205\250\346\216\222\345\210\227.md"
@@ -19,7 +19,7 @@
## 代码
-```Python
+```python
class Solution:
res = []
path = []
diff --git "a/Solutions/\345\211\221\346\214\207 Offer II 085. \347\224\237\346\210\220\345\214\271\351\205\215\347\232\204\346\213\254\345\217\267.md" "b/Solutions/\345\211\221\346\214\207 Offer II 085. \347\224\237\346\210\220\345\214\271\351\205\215\347\232\204\346\213\254\345\217\267.md"
index ff4c7abc..3166cdad 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer II 085. \347\224\237\346\210\220\345\214\271\351\205\215\347\232\204\346\213\254\345\217\267.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer II 085. \347\224\237\346\210\220\345\214\271\351\205\215\347\232\204\346\213\254\345\217\267.md"
@@ -21,7 +21,7 @@
## 代码
-```Python
+```python
class Solution:
def generateParenthesis(self, n: int) -> List[str]:
def backtrack(parenthesis, symbol, index):
diff --git "a/Solutions/\345\211\221\346\214\207 Offer II 086. \345\210\206\345\211\262\345\233\236\346\226\207\345\255\220\345\255\227\347\254\246\344\270\262.md" "b/Solutions/\345\211\221\346\214\207 Offer II 086. \345\210\206\345\211\262\345\233\236\346\226\207\345\255\220\345\255\227\347\254\246\344\270\262.md"
index 7c82bae1..7baed53d 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer II 086. \345\210\206\345\211\262\345\233\236\346\226\207\345\255\220\345\255\227\347\254\246\344\270\262.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer II 086. \345\210\206\345\211\262\345\233\236\346\226\207\345\255\220\345\255\227\347\254\246\344\270\262.md"
@@ -26,7 +26,7 @@
## 代码
-```Python
+```python
class Solution:
res = []
path = []
diff --git "a/Solutions/\345\211\221\346\214\207 Offer II 087. \345\244\215\345\216\237 IP.md" "b/Solutions/\345\211\221\346\214\207 Offer II 087. \345\244\215\345\216\237 IP.md"
index a597d908..65ec9111 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer II 087. \345\244\215\345\216\237 IP.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer II 087. \345\244\215\345\216\237 IP.md"
@@ -29,7 +29,7 @@
## 代码
-```Python
+```python
class Solution:
res = []
diff --git "a/Solutions/\345\211\221\346\214\207 Offer II 088. \347\210\254\346\245\274\346\242\257\347\232\204\346\234\200\345\260\221\346\210\220\346\234\254.md" "b/Solutions/\345\211\221\346\214\207 Offer II 088. \347\210\254\346\245\274\346\242\257\347\232\204\346\234\200\345\260\221\346\210\220\346\234\254.md"
index 9365292c..47158b9b 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer II 088. \347\210\254\346\245\274\346\242\257\347\232\204\346\234\200\345\260\221\346\210\220\346\234\254.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer II 088. \347\210\254\346\245\274\346\242\257\347\232\204\346\234\200\345\260\221\346\210\220\346\234\254.md"
@@ -23,7 +23,7 @@
## 代码
-```Python
+```python
class Solution:
def minCostClimbingStairs(self, cost: List[int]) -> int:
size = len(cost)
diff --git "a/Solutions/\345\211\221\346\214\207 Offer II 089. \346\210\277\345\261\213\345\201\267\347\233\227.md" "b/Solutions/\345\211\221\346\214\207 Offer II 089. \346\210\277\345\261\213\345\201\267\347\233\227.md"
index 44de06c5..f462ab3e 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer II 089. \346\210\277\345\261\213\345\201\267\347\233\227.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer II 089. \346\210\277\345\261\213\345\201\267\347\233\227.md"
@@ -28,7 +28,7 @@ $dp[i] = \begin{cases} \begin{array} {**lr**} nums[0] & i = 0 \cr max( nums[0],
## 代码
-```Python
+```python
class Solution:
def rob(self, nums: List[int]) -> int:
size = len(nums)
diff --git "a/Solutions/\345\211\221\346\214\207 Offer II 090. \347\216\257\345\275\242\346\210\277\345\261\213\345\201\267\347\233\227.md" "b/Solutions/\345\211\221\346\214\207 Offer II 090. \347\216\257\345\275\242\346\210\277\345\261\213\345\201\267\347\233\227.md"
index 697b5687..90b33ec2 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer II 090. \347\216\257\345\275\242\346\210\277\345\261\213\345\201\267\347\233\227.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer II 090. \347\216\257\345\275\242\346\210\277\345\261\213\345\201\267\347\233\227.md"
@@ -36,7 +36,7 @@ $dp[i] = \begin{cases} nums[0], & i = 0 \cr max( nums[0], nums[1]) & i = 1 \cr
## 代码
-```Python
+```python
class Solution:
def rob(self, nums: List[int]) -> int:
def helper(nums):
diff --git "a/Solutions/\345\211\221\346\214\207 Offer II 093. \346\234\200\351\225\277\346\226\220\346\263\242\351\202\243\345\245\221\346\225\260\345\210\227.md" "b/Solutions/\345\211\221\346\214\207 Offer II 093. \346\234\200\351\225\277\346\226\220\346\263\242\351\202\243\345\245\221\346\225\260\345\210\227.md"
index 742a6736..9bcae110 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer II 093. \346\234\200\351\225\277\346\226\220\346\263\242\351\202\243\345\245\221\346\225\260\345\210\227.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer II 093. \346\234\200\351\225\277\346\226\220\346\263\242\351\202\243\345\245\221\346\225\260\345\210\227.md"
@@ -36,7 +36,7 @@
下面是暴力做法的代码:
-```Python
+```python
class Solution:
def lenLongestFibSubseq(self, arr: List[int]) -> int:
size = len(arr)
@@ -72,7 +72,7 @@ class Solution:
使用哈希表优化之后的代码如下:
-```Python
+```python
class Solution:
def lenLongestFibSubseq(self, arr: List[int]) -> int:
size = len(arr)
@@ -119,7 +119,7 @@ class Solution:
## 代码
-```Python
+```python
class Solution:
def lenLongestFibSubseq(self, arr: List[int]) -> int:
size = len(arr)
diff --git "a/Solutions/\345\211\221\346\214\207 Offer II 095. \346\234\200\351\225\277\345\205\254\345\205\261\345\255\220\345\272\217\345\210\227.md" "b/Solutions/\345\211\221\346\214\207 Offer II 095. \346\234\200\351\225\277\345\205\254\345\205\261\345\255\220\345\272\217\345\210\227.md"
index 8ab20b6c..32c6c7e8 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer II 095. \346\234\200\351\225\277\345\205\254\345\205\261\345\255\220\345\272\217\345\210\227.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer II 095. \346\234\200\351\225\277\345\205\254\345\205\261\345\255\220\345\272\217\345\210\227.md"
@@ -29,7 +29,7 @@
## 代码
-```Python
+```python
class Solution:
def longestCommonSubsequence(self, text1: str, text2: str) -> int:
size1 = len(text1)
diff --git "a/Solutions/\345\211\221\346\214\207 Offer II 097. \345\255\220\345\272\217\345\210\227\347\232\204\346\225\260\347\233\256.md" "b/Solutions/\345\211\221\346\214\207 Offer II 097. \345\255\220\345\272\217\345\210\227\347\232\204\346\225\260\347\233\256.md"
index 2f29d64e..f3068bfd 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer II 097. \345\255\220\345\272\217\345\210\227\347\232\204\346\225\260\347\233\256.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer II 097. \345\255\220\345\272\217\345\210\227\347\232\204\346\225\260\347\233\256.md"
@@ -32,7 +32,7 @@
## 代码
-```Python
+```python
class Solution:
def numDistinct(self, s: str, t: str) -> int:
size_s = len(s)
diff --git "a/Solutions/\345\211\221\346\214\207 Offer II 098. \350\267\257\345\276\204\347\232\204\346\225\260\347\233\256.md" "b/Solutions/\345\211\221\346\214\207 Offer II 098. \350\267\257\345\276\204\347\232\204\346\225\260\347\233\256.md"
index cc1893bd..2ad108f5 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer II 098. \350\267\257\345\276\204\347\232\204\346\225\260\347\233\256.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer II 098. \350\267\257\345\276\204\347\232\204\346\225\260\347\233\256.md"
@@ -15,7 +15,7 @@
## 代码
-```Python
+```python
class Solution:
def uniquePaths(self, m: int, n: int) -> int:
dp = [1 for _ in range(n)]
diff --git "a/Solutions/\345\211\221\346\214\207 Offer II 101. \345\210\206\345\211\262\347\255\211\345\222\214\345\255\220\351\233\206.md" "b/Solutions/\345\211\221\346\214\207 Offer II 101. \345\210\206\345\211\262\347\255\211\345\222\214\345\255\220\351\233\206.md"
index 8cb33a1c..4e9c50e2 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer II 101. \345\210\206\345\211\262\347\255\211\345\222\214\345\255\220\351\233\206.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer II 101. \345\210\206\345\211\262\347\255\211\345\222\214\345\255\220\351\233\206.md"
@@ -23,7 +23,7 @@
## 代码
-```Python
+```python
class Solution:
def canPartition(self, nums: List[int]) -> bool:
size = 100010
diff --git "a/Solutions/\345\211\221\346\214\207 Offer II 102. \345\212\240\345\207\217\347\232\204\347\233\256\346\240\207\345\200\274.md" "b/Solutions/\345\211\221\346\214\207 Offer II 102. \345\212\240\345\207\217\347\232\204\347\233\256\346\240\207\345\200\274.md"
index 6ce3f86d..8ad9c352 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer II 102. \345\212\240\345\207\217\347\232\204\347\233\256\346\240\207\345\200\274.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer II 102. \345\212\240\345\207\217\347\232\204\347\233\256\346\240\207\345\200\274.md"
@@ -25,7 +25,7 @@
## 代码
-```Python
+```python
class Solution:
def findTargetSumWays(self, nums: List[int], target: int) -> int:
sum_nums = sum(nums)
diff --git "a/Solutions/\345\211\221\346\214\207 Offer II 103. \346\234\200\345\260\221\347\232\204\347\241\254\345\270\201\346\225\260\347\233\256.md" "b/Solutions/\345\211\221\346\214\207 Offer II 103. \346\234\200\345\260\221\347\232\204\347\241\254\345\270\201\346\225\260\347\233\256.md"
index b0d3a25b..0546b3ea 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer II 103. \346\234\200\345\260\221\347\232\204\347\241\254\345\270\201\346\225\260\347\233\256.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer II 103. \346\234\200\345\260\221\347\232\204\347\241\254\345\270\201\346\225\260\347\233\256.md"
@@ -21,7 +21,7 @@
## 代码
-```Python
+```python
class Solution:
def coinChange(self, coins: List[int], amount: int) -> int:
dp = [float('inf') for _ in range(amount + 1)]
diff --git "a/Solutions/\345\211\221\346\214\207 Offer II 104. \346\216\222\345\210\227\347\232\204\346\225\260\347\233\256.md" "b/Solutions/\345\211\221\346\214\207 Offer II 104. \346\216\222\345\210\227\347\232\204\346\225\260\347\233\256.md"
index 793200e9..e0ad3d4e 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer II 104. \346\216\222\345\210\227\347\232\204\346\225\260\347\233\256.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer II 104. \346\216\222\345\210\227\347\232\204\346\225\260\347\233\256.md"
@@ -21,7 +21,7 @@
## 代码
-```Python
+```python
class Solution:
def combinationSum4(self, nums: List[int], target: int) -> int:
dp = [0 for _ in range(target + 1)]
diff --git "a/Solutions/\345\211\221\346\214\207 Offer II 105. \345\262\233\345\261\277\347\232\204\346\234\200\345\244\247\351\235\242\347\247\257.md" "b/Solutions/\345\211\221\346\214\207 Offer II 105. \345\262\233\345\261\277\347\232\204\346\234\200\345\244\247\351\235\242\347\247\257.md"
index 3f6353ab..f147f252 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer II 105. \345\262\233\345\261\277\347\232\204\346\234\200\345\244\247\351\235\242\347\247\257.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer II 105. \345\262\233\345\261\277\347\232\204\346\234\200\345\244\247\351\235\242\347\247\257.md"
@@ -13,7 +13,7 @@
## 代码
-```Python
+```python
class Solution:
def dfs(self, grid, i, j):
size_n = len(grid)
diff --git "a/Solutions/\345\211\221\346\214\207 Offer II 106. \344\272\214\345\210\206\345\233\276.md" "b/Solutions/\345\211\221\346\214\207 Offer II 106. \344\272\214\345\210\206\345\233\276.md"
index 5f4e8548..115b7f9d 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer II 106. \344\272\214\345\210\206\345\233\276.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer II 106. \344\272\214\345\210\206\345\233\276.md"
@@ -31,7 +31,7 @@
## 代码
-```Python
+```python
class Solution:
def dfs(self, graph, colors, i, color):
colors[i] = color
diff --git "a/Solutions/\345\211\221\346\214\207 Offer II 107. \347\237\251\351\230\265\344\270\255\347\232\204\350\267\235\347\246\273.md" "b/Solutions/\345\211\221\346\214\207 Offer II 107. \347\237\251\351\230\265\344\270\255\347\232\204\350\267\235\347\246\273.md"
index 4ea62ae8..0fece48b 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer II 107. \347\237\251\351\230\265\344\270\255\347\232\204\350\267\235\347\246\273.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer II 107. \347\237\251\351\230\265\344\270\255\347\232\204\350\267\235\347\246\273.md"
@@ -17,7 +17,7 @@
## 代码
-```Python
+```python
class Solution:
def updateMatrix(self, mat: List[List[int]]) -> List[List[int]]:
row_count = len(mat)
diff --git "a/Solutions/\345\211\221\346\214\207 Offer II 108. \345\215\225\350\257\215\346\274\224\345\217\230.md" "b/Solutions/\345\211\221\346\214\207 Offer II 108. \345\215\225\350\257\215\346\274\224\345\217\230.md"
index 182e35ad..f42ef7c0 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer II 108. \345\215\225\350\257\215\346\274\224\345\217\230.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer II 108. \345\215\225\350\257\215\346\274\224\345\217\230.md"
@@ -22,7 +22,7 @@
## 代码
-```Python
+```python
class Solution:
def ladderLength(self, beginWord: str, endWord: str, wordList: List[str]) -> int:
if not wordList or endWord not in wordList:
diff --git "a/Solutions/\345\211\221\346\214\207 Offer II 109. \345\274\200\345\257\206\347\240\201\351\224\201.md" "b/Solutions/\345\211\221\346\214\207 Offer II 109. \345\274\200\345\257\206\347\240\201\351\224\201.md"
index 4ec0a544..2f9d7233 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer II 109. \345\274\200\345\257\206\347\240\201\351\224\201.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer II 109. \345\274\200\345\257\206\347\240\201\351\224\201.md"
@@ -27,7 +27,7 @@
## 代码
-```Python
+```python
class Solution:
def openLock(self, deadends: List[str], target: str) -> int:
queue = collections.deque(['0000'])
diff --git "a/Solutions/\345\211\221\346\214\207 Offer II 111. \350\256\241\347\256\227\351\231\244\346\263\225.md" "b/Solutions/\345\211\221\346\214\207 Offer II 111. \350\256\241\347\256\227\351\231\244\346\263\225.md"
index e46c5371..31cb5e2a 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer II 111. \350\256\241\347\256\227\351\231\244\346\263\225.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer II 111. \350\256\241\347\256\227\351\231\244\346\263\225.md"
@@ -42,7 +42,7 @@
## 代码
-```Python
+```python
class UnionFind:
def __init__(self, n):
diff --git "a/Solutions/\345\211\221\346\214\207 Offer II 112. \346\234\200\351\225\277\351\200\222\345\242\236\350\267\257\345\276\204.md" "b/Solutions/\345\211\221\346\214\207 Offer II 112. \346\234\200\351\225\277\351\200\222\345\242\236\350\267\257\345\276\204.md"
index 996bd33e..08bd1435 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer II 112. \346\234\200\351\225\277\351\200\222\345\242\236\350\267\257\345\276\204.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer II 112. \346\234\200\351\225\277\351\200\222\345\242\236\350\267\257\345\276\204.md"
@@ -15,7 +15,7 @@
## 代码
-```Python
+```python
class Solution:
max_len = 0
directions = {(1, 0), (-1, 0), (0, 1), (0, -1)}
diff --git "a/Solutions/\345\211\221\346\214\207 Offer II 113. \350\257\276\347\250\213\351\241\272\345\272\217.md" "b/Solutions/\345\211\221\346\214\207 Offer II 113. \350\257\276\347\250\213\351\241\272\345\272\217.md"
index d6b10500..be9e83b2 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer II 113. \350\257\276\347\250\213\351\241\272\345\272\217.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer II 113. \350\257\276\347\250\213\351\241\272\345\272\217.md"
@@ -24,7 +24,7 @@
## 代码
-```Python
+```python
class Solution:
def findOrder(self, numCourses: int, prerequisites: List[List[int]]) -> List[int]:
indegrees = [0 for _ in range(numCourses)]
diff --git "a/Solutions/\345\211\221\346\214\207 Offer II 116. \347\234\201\344\273\275\346\225\260\351\207\217.md" "b/Solutions/\345\211\221\346\214\207 Offer II 116. \347\234\201\344\273\275\346\225\260\351\207\217.md"
index c53bdb24..9e0dc625 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer II 116. \347\234\201\344\273\275\346\225\260\351\207\217.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer II 116. \347\234\201\344\273\275\346\225\260\351\207\217.md"
@@ -21,7 +21,7 @@
## 代码
-```Python
+```python
class UnionFind:
def __init__(self, n):
diff --git "a/Solutions/\345\211\221\346\214\207 Offer II 118. \345\244\232\344\275\231\347\232\204\350\276\271.md" "b/Solutions/\345\211\221\346\214\207 Offer II 118. \345\244\232\344\275\231\347\232\204\350\276\271.md"
index 62e072d8..f34af08c 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer II 118. \345\244\232\344\275\231\347\232\204\350\276\271.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer II 118. \345\244\232\344\275\231\347\232\204\350\276\271.md"
@@ -19,7 +19,7 @@
## 代码
-```Python
+```python
class UnionFind:
def __init__(self, n):
diff --git "a/Solutions/\345\211\221\346\214\207 Offer II 119. \346\234\200\351\225\277\350\277\236\347\273\255\345\272\217\345\210\227.md" "b/Solutions/\345\211\221\346\214\207 Offer II 119. \346\234\200\351\225\277\350\277\236\347\273\255\345\272\217\345\210\227.md"
index 92b29e21..e5a87c1a 100644
--- "a/Solutions/\345\211\221\346\214\207 Offer II 119. \346\234\200\351\225\277\350\277\236\347\273\255\345\272\217\345\210\227.md"
+++ "b/Solutions/\345\211\221\346\214\207 Offer II 119. \346\234\200\351\225\277\350\277\236\347\273\255\345\272\217\345\210\227.md"
@@ -22,7 +22,7 @@
## 代码
-```Python
+```python
class Solution:
def longestConsecutive(self, nums: List[int]) -> int:
ans = 0
diff --git "a/Solutions/\351\235\242\350\257\225\351\242\230 01.07. \346\227\213\350\275\254\347\237\251\351\230\265.md" "b/Solutions/\351\235\242\350\257\225\351\242\230 01.07. \346\227\213\350\275\254\347\237\251\351\230\265.md"
index d89a8158..e812c7a9 100644
--- "a/Solutions/\351\235\242\350\257\225\351\242\230 01.07. \346\227\213\350\275\254\347\237\251\351\230\265.md"
+++ "b/Solutions/\351\235\242\350\257\225\351\242\230 01.07. \346\227\213\350\275\254\347\237\251\351\230\265.md"
@@ -46,7 +46,7 @@
## 代码
-```Python
+```python
class Solution:
def rotate(self, matrix: List[List[int]]) -> None:
"""
diff --git "a/Solutions/\351\235\242\350\257\225\351\242\230 01.08. \351\233\266\347\237\251\351\230\265.md" "b/Solutions/\351\235\242\350\257\225\351\242\230 01.08. \351\233\266\347\237\251\351\230\265.md"
index 5479e592..18088f93 100644
--- "a/Solutions/\351\235\242\350\257\225\351\242\230 01.08. \351\233\266\347\237\251\351\230\265.md"
+++ "b/Solutions/\351\235\242\350\257\225\351\242\230 01.08. \351\233\266\347\237\251\351\230\265.md"
@@ -25,7 +25,7 @@
## 代码
-```Python
+```python
class Solution:
def setZeroes(self, matrix: List[List[int]]) -> None:
"""
diff --git "a/Solutions/\351\235\242\350\257\225\351\242\230 02.02. \350\277\224\345\233\236\345\200\222\346\225\260\347\254\254 k \344\270\252\350\212\202\347\202\271.md" "b/Solutions/\351\235\242\350\257\225\351\242\230 02.02. \350\277\224\345\233\236\345\200\222\346\225\260\347\254\254 k \344\270\252\350\212\202\347\202\271.md"
index 74bf4eb2..2ea95755 100644
--- "a/Solutions/\351\235\242\350\257\225\351\242\230 02.02. \350\277\224\345\233\236\345\200\222\346\225\260\347\254\254 k \344\270\252\350\212\202\347\202\271.md"
+++ "b/Solutions/\351\235\242\350\257\225\351\242\230 02.02. \350\277\224\345\233\236\345\200\222\346\225\260\347\254\254 k \344\270\252\350\212\202\347\202\271.md"
@@ -17,7 +17,7 @@
## 代码
-```Python
+```python
class Solution:
def kthToLast(self, head: ListNode, k: int) -> int:
slow = head
diff --git "a/Solutions/\351\235\242\350\257\225\351\242\230 02.05. \351\223\276\350\241\250\346\261\202\345\222\214.md" "b/Solutions/\351\235\242\350\257\225\351\242\230 02.05. \351\223\276\350\241\250\346\261\202\345\222\214.md"
index 5393cb61..9708ba11 100644
--- "a/Solutions/\351\235\242\350\257\225\351\242\230 02.05. \351\223\276\350\241\250\346\261\202\345\222\214.md"
+++ "b/Solutions/\351\235\242\350\257\225\351\242\230 02.05. \351\223\276\350\241\250\346\261\202\345\222\214.md"
@@ -15,7 +15,7 @@
## 代码
-```Python
+```python
class Solution:
def addTwoNumbers(self, l1: ListNode, l2: ListNode) -> ListNode:
head = curr = ListNode(0)
diff --git "a/Solutions/\351\235\242\350\257\225\351\242\230 02.06. \345\233\236\346\226\207\351\223\276\350\241\250.md" "b/Solutions/\351\235\242\350\257\225\351\242\230 02.06. \345\233\236\346\226\207\351\223\276\350\241\250.md"
index 35dfaa75..bc2f1d0b 100644
--- "a/Solutions/\351\235\242\350\257\225\351\242\230 02.06. \345\233\236\346\226\207\351\223\276\350\241\250.md"
+++ "b/Solutions/\351\235\242\350\257\225\351\242\230 02.06. \345\233\236\346\226\207\351\223\276\350\241\250.md"
@@ -15,7 +15,7 @@
## 代码
-```Python
+```python
class Solution:
def isPalindrome(self, head: ListNode) -> bool:
nodes = []
diff --git "a/Solutions/\351\235\242\350\257\225\351\242\230 02.07. \351\223\276\350\241\250\347\233\270\344\272\244.md" "b/Solutions/\351\235\242\350\257\225\351\242\230 02.07. \351\223\276\350\241\250\347\233\270\344\272\244.md"
index 5706e282..06137e81 100644
--- "a/Solutions/\351\235\242\350\257\225\351\242\230 02.07. \351\223\276\350\241\250\347\233\270\344\272\244.md"
+++ "b/Solutions/\351\235\242\350\257\225\351\242\230 02.07. \351\223\276\350\241\250\347\233\270\344\272\244.md"
@@ -35,7 +35,7 @@
## 代码
-```Python
+```python
class Solution:
def getIntersectionNode(self, headA: ListNode, headB: ListNode) -> ListNode:
if headA == None or headB == None:
diff --git "a/Solutions/\351\235\242\350\257\225\351\242\230 02.08. \347\216\257\350\267\257\346\243\200\346\265\213.md" "b/Solutions/\351\235\242\350\257\225\351\242\230 02.08. \347\216\257\350\267\257\346\243\200\346\265\213.md"
index c8412313..f0e36c02 100644
--- "a/Solutions/\351\235\242\350\257\225\351\242\230 02.08. \347\216\257\350\267\257\346\243\200\346\265\213.md"
+++ "b/Solutions/\351\235\242\350\257\225\351\242\230 02.08. \347\216\257\350\267\257\346\243\200\346\265\213.md"
@@ -23,7 +23,7 @@ $2(a + b) = a + n(b + c) + b$。可以推出:$a = c + (n-1)(b + c)$。
## 代码
-```Python
+```python
class Solution:
def detectCycle(self, head: ListNode) -> ListNode:
fast, slow = head, head
diff --git "a/Solutions/\351\235\242\350\257\225\351\242\230 03.02. \346\240\210\347\232\204\346\234\200\345\260\217\345\200\274.md" "b/Solutions/\351\235\242\350\257\225\351\242\230 03.02. \346\240\210\347\232\204\346\234\200\345\260\217\345\200\274.md"
index d58b9055..2e539d31 100644
--- "a/Solutions/\351\235\242\350\257\225\351\242\230 03.02. \346\240\210\347\232\204\346\234\200\345\260\217\345\200\274.md"
+++ "b/Solutions/\351\235\242\350\257\225\351\242\230 03.02. \346\240\210\347\232\204\346\234\200\345\260\217\345\200\274.md"
@@ -18,7 +18,7 @@
## 代码
-```Python
+```python
class MinStack:
def __init__(self):
diff --git "a/Solutions/\351\235\242\350\257\225\351\242\230 03.04. \345\214\226\346\240\210\344\270\272\351\230\237.md" "b/Solutions/\351\235\242\350\257\225\351\242\230 03.04. \345\214\226\346\240\210\344\270\272\351\230\237.md"
index 2973b437..391036ae 100644
--- "a/Solutions/\351\235\242\350\257\225\351\242\230 03.04. \345\214\226\346\240\210\344\270\272\351\230\237.md"
+++ "b/Solutions/\351\235\242\350\257\225\351\242\230 03.04. \345\214\226\346\240\210\344\270\272\351\230\237.md"
@@ -18,7 +18,7 @@
## 代码
-```Python
+```python
class MyQueue:
def __init__(self):
diff --git "a/Solutions/\351\235\242\350\257\225\351\242\230 04.02. \346\234\200\345\260\217\351\253\230\345\272\246\346\240\221.md" "b/Solutions/\351\235\242\350\257\225\351\242\230 04.02. \346\234\200\345\260\217\351\253\230\345\272\246\346\240\221.md"
index 99b14431..3c5f5041 100644
--- "a/Solutions/\351\235\242\350\257\225\351\242\230 04.02. \346\234\200\345\260\217\351\253\230\345\272\246\346\240\221.md"
+++ "b/Solutions/\351\235\242\350\257\225\351\242\230 04.02. \346\234\200\345\260\217\351\253\230\345\272\246\346\240\221.md"
@@ -15,7 +15,7 @@
## 代码
-```Python
+```python
class Solution:
def sortedArrayToBST(self, nums: List[int]) -> TreeNode:
size = len(nums)
diff --git "a/Solutions/\351\235\242\350\257\225\351\242\230 04.05. \345\220\210\346\263\225\344\272\214\345\217\211\346\220\234\347\264\242\346\240\221.md" "b/Solutions/\351\235\242\350\257\225\351\242\230 04.05. \345\220\210\346\263\225\344\272\214\345\217\211\346\220\234\347\264\242\346\240\221.md"
index 25c55507..a04e652c 100644
--- "a/Solutions/\351\235\242\350\257\225\351\242\230 04.05. \345\220\210\346\263\225\344\272\214\345\217\211\346\220\234\347\264\242\346\240\221.md"
+++ "b/Solutions/\351\235\242\350\257\225\351\242\230 04.05. \345\220\210\346\263\225\344\272\214\345\217\211\346\220\234\347\264\242\346\240\221.md"
@@ -27,7 +27,7 @@
## 代码
-```Python
+```python
class Solution:
def isValidBST(self, root: TreeNode) -> bool:
def preorderTraversal(root, min_v, max_v):
diff --git "a/Solutions/\351\235\242\350\257\225\351\242\230 04.06. \345\220\216\347\273\247\350\200\205.md" "b/Solutions/\351\235\242\350\257\225\351\242\230 04.06. \345\220\216\347\273\247\350\200\205.md"
index 79beefe1..f344b8f8 100644
--- "a/Solutions/\351\235\242\350\257\225\351\242\230 04.06. \345\220\216\347\273\247\350\200\205.md"
+++ "b/Solutions/\351\235\242\350\257\225\351\242\230 04.06. \345\220\216\347\273\247\350\200\205.md"
@@ -18,7 +18,7 @@
## 代码
-```Python
+```python
class Solution:
def inorderSuccessor(self, root: TreeNode, p: TreeNode) -> TreeNode:
if not p or not root:
diff --git "a/Solutions/\351\235\242\350\257\225\351\242\230 04.08. \351\246\226\344\270\252\345\205\261\345\220\214\347\245\226\345\205\210.md" "b/Solutions/\351\235\242\350\257\225\351\242\230 04.08. \351\246\226\344\270\252\345\205\261\345\220\214\347\245\226\345\205\210.md"
index 6df7ae1f..029ca286 100644
--- "a/Solutions/\351\235\242\350\257\225\351\242\230 04.08. \351\246\226\344\270\252\345\205\261\345\220\214\347\245\226\345\205\210.md"
+++ "b/Solutions/\351\235\242\350\257\225\351\242\230 04.08. \351\246\226\344\270\252\345\205\261\345\220\214\347\245\226\345\205\210.md"
@@ -37,7 +37,7 @@
## 代码
-```Python
+```python
class Solution:
def lowestCommonAncestor(self, root: TreeNode, p: TreeNode, q: TreeNode) -> TreeNode:
if root == p or root == q:
diff --git "a/Solutions/\351\235\242\350\257\225\351\242\230 04.12. \346\261\202\345\222\214\350\267\257\345\276\204.md" "b/Solutions/\351\235\242\350\257\225\351\242\230 04.12. \346\261\202\345\222\214\350\267\257\345\276\204.md"
index 90f283cc..c1d57d5a 100644
--- "a/Solutions/\351\235\242\350\257\225\351\242\230 04.12. \346\261\202\345\222\214\350\267\257\345\276\204.md"
+++ "b/Solutions/\351\235\242\350\257\225\351\242\230 04.12. \346\261\202\345\222\214\350\267\257\345\276\204.md"
@@ -35,7 +35,7 @@
## 代码
-```Python
+```python
```
diff --git "a/Solutions/\351\235\242\350\257\225\351\242\230 08.04. \345\271\202\351\233\206.md" "b/Solutions/\351\235\242\350\257\225\351\242\230 08.04. \345\271\202\351\233\206.md"
index 1a2dc605..4ae7a3e4 100644
--- "a/Solutions/\351\235\242\350\257\225\351\242\230 08.04. \345\271\202\351\233\206.md"
+++ "b/Solutions/\351\235\242\350\257\225\351\242\230 08.04. \345\271\202\351\233\206.md"
@@ -15,7 +15,7 @@
## 代码
-```Python
+```python
class Solution:
def subsets(self, nums: List[int]) -> List[List[int]]:
def backtrack(size, subset, index):
diff --git "a/Solutions/\351\235\242\350\257\225\351\242\230 08.07. \346\227\240\351\207\215\345\244\215\345\255\227\347\254\246\344\270\262\347\232\204\346\216\222\345\210\227\347\273\204\345\220\210.md" "b/Solutions/\351\235\242\350\257\225\351\242\230 08.07. \346\227\240\351\207\215\345\244\215\345\255\227\347\254\246\344\270\262\347\232\204\346\216\222\345\210\227\347\273\204\345\220\210.md"
index 851b225a..0ad3836e 100644
--- "a/Solutions/\351\235\242\350\257\225\351\242\230 08.07. \346\227\240\351\207\215\345\244\215\345\255\227\347\254\246\344\270\262\347\232\204\346\216\222\345\210\227\347\273\204\345\220\210.md"
+++ "b/Solutions/\351\235\242\350\257\225\351\242\230 08.07. \346\227\240\351\207\215\345\244\215\345\255\227\347\254\246\344\270\262\347\232\204\346\216\222\345\210\227\347\273\204\345\220\210.md"
@@ -15,7 +15,7 @@
## 代码
-```Python
+```python
class Solution:
res = []
path = []
diff --git "a/Solutions/\351\235\242\350\257\225\351\242\230 08.08. \346\234\211\351\207\215\345\244\215\345\255\227\347\254\246\344\270\262\347\232\204\346\216\222\345\210\227\347\273\204\345\220\210.md" "b/Solutions/\351\235\242\350\257\225\351\242\230 08.08. \346\234\211\351\207\215\345\244\215\345\255\227\347\254\246\344\270\262\347\232\204\346\216\222\345\210\227\347\273\204\345\220\210.md"
index e23df87d..4d289e24 100644
--- "a/Solutions/\351\235\242\350\257\225\351\242\230 08.08. \346\234\211\351\207\215\345\244\215\345\255\227\347\254\246\344\270\262\347\232\204\346\216\222\345\210\227\347\273\204\345\220\210.md"
+++ "b/Solutions/\351\235\242\350\257\225\351\242\230 08.08. \346\234\211\351\207\215\345\244\215\345\255\227\347\254\246\344\270\262\347\232\204\346\216\222\345\210\227\347\273\204\345\220\210.md"
@@ -19,7 +19,7 @@
## 代码
-```Python
+```python
class Solution:
res = []
path = []
diff --git "a/Solutions/\351\235\242\350\257\225\351\242\230 08.09. \346\213\254\345\217\267.md" "b/Solutions/\351\235\242\350\257\225\351\242\230 08.09. \346\213\254\345\217\267.md"
index e9b43a72..52c7f584 100644
--- "a/Solutions/\351\235\242\350\257\225\351\242\230 08.09. \346\213\254\345\217\267.md"
+++ "b/Solutions/\351\235\242\350\257\225\351\242\230 08.09. \346\213\254\345\217\267.md"
@@ -21,7 +21,7 @@
## 代码
-```Python
+```python
class Solution:
def generateParenthesis(self, n: int) -> List[str]:
def backtrack(parenthesis, symbol, index):
diff --git "a/Solutions/\351\235\242\350\257\225\351\242\230 08.10. \351\242\234\350\211\262\345\241\253\345\205\205.md" "b/Solutions/\351\235\242\350\257\225\351\242\230 08.10. \351\242\234\350\211\262\345\241\253\345\205\205.md"
index cdd8e403..90b8a60c 100644
--- "a/Solutions/\351\235\242\350\257\225\351\242\230 08.10. \351\242\234\350\211\262\345\241\253\345\205\205.md"
+++ "b/Solutions/\351\235\242\350\257\225\351\242\230 08.10. \351\242\234\350\211\262\345\241\253\345\205\205.md"
@@ -19,7 +19,7 @@
## 代码
-```Python
+```python
class Solution:
directs = [(0, 1), (0, -1), (1, 0), (-1, 0)]
diff --git "a/Solutions/\351\235\242\350\257\225\351\242\230 08.12. \345\205\253\347\232\207\345\220\216.md" "b/Solutions/\351\235\242\350\257\225\351\242\230 08.12. \345\205\253\347\232\207\345\220\216.md"
index 37d2a1c0..f006a44f 100644
--- "a/Solutions/\351\235\242\350\257\225\351\242\230 08.12. \345\205\253\347\232\207\345\220\216.md"
+++ "b/Solutions/\351\235\242\350\257\225\351\242\230 08.12. \345\205\253\347\232\207\345\220\216.md"
@@ -27,7 +27,7 @@
## 代码
-```Python
+```python
class Solution:
res = []
def backtrack(self, n: int, row: int, chessboard: List[List[str]]):
diff --git "a/Solutions/\351\235\242\350\257\225\351\242\230 10.01. \345\220\210\345\271\266\346\216\222\345\272\217\347\232\204\346\225\260\347\273\204.md" "b/Solutions/\351\235\242\350\257\225\351\242\230 10.01. \345\220\210\345\271\266\346\216\222\345\272\217\347\232\204\346\225\260\347\273\204.md"
index 9726d9dc..32c5c1b9 100644
--- "a/Solutions/\351\235\242\350\257\225\351\242\230 10.01. \345\220\210\345\271\266\346\216\222\345\272\217\347\232\204\346\225\260\347\273\204.md"
+++ "b/Solutions/\351\235\242\350\257\225\351\242\230 10.01. \345\220\210\345\271\266\346\216\222\345\272\217\347\232\204\346\225\260\347\273\204.md"
@@ -17,7 +17,7 @@
- 示例 1:
-```Python
+```python
输入:
A = [1,2,3,0,0,0], m = 3
B = [2,5,6], n = 3
@@ -36,7 +36,7 @@ B = [2,5,6], n = 3
### 思路 1:代码
-```Python
+```python
class Solution:
def merge(self, A: List[int], m: int, B: List[int], n: int) -> None:
"""
diff --git "a/Solutions/\351\235\242\350\257\225\351\242\230 10.02. \345\217\230\344\275\215\350\257\215\347\273\204.md" "b/Solutions/\351\235\242\350\257\225\351\242\230 10.02. \345\217\230\344\275\215\350\257\215\347\273\204.md"
index 4b18460d..8243e315 100644
--- "a/Solutions/\351\235\242\350\257\225\351\242\230 10.02. \345\217\230\344\275\215\350\257\215\347\273\204.md"
+++ "b/Solutions/\351\235\242\350\257\225\351\242\230 10.02. \345\217\230\344\275\215\350\257\215\347\273\204.md"
@@ -19,7 +19,7 @@
## 代码
-```Python
+```python
class Solution:
def groupAnagrams(self, strs: List[str]) -> List[List[str]]:
str_dict = dict()
diff --git "a/Solutions/\351\235\242\350\257\225\351\242\230 10.09. \346\216\222\345\272\217\347\237\251\351\230\265\346\237\245\346\211\276.md" "b/Solutions/\351\235\242\350\257\225\351\242\230 10.09. \346\216\222\345\272\217\347\237\251\351\230\265\346\237\245\346\211\276.md"
index 2a255419..002edcd5 100644
--- "a/Solutions/\351\235\242\350\257\225\351\242\230 10.09. \346\216\222\345\272\217\347\237\251\351\230\265\346\237\245\346\211\276.md"
+++ "b/Solutions/\351\235\242\350\257\225\351\242\230 10.09. \346\216\222\345\272\217\347\237\251\351\230\265\346\237\245\346\211\276.md"
@@ -23,7 +23,7 @@
## 代码
-```Python
+```python
class Solution:
def diagonalBinarySearch(self, matrix, diagonal, target):
left = 0
diff --git "a/Solutions/\351\235\242\350\257\225\351\242\230 16.02. \345\215\225\350\257\215\351\242\221\347\216\207.md" "b/Solutions/\351\235\242\350\257\225\351\242\230 16.02. \345\215\225\350\257\215\351\242\221\347\216\207.md"
index fdd72854..0d243ae1 100644
--- "a/Solutions/\351\235\242\350\257\225\351\242\230 16.02. \345\215\225\350\257\215\351\242\221\347\216\207.md"
+++ "b/Solutions/\351\235\242\350\257\225\351\242\230 16.02. \345\215\225\350\257\215\351\242\221\347\216\207.md"
@@ -22,7 +22,7 @@
## 代码
-```Python
+```python
class Trie:
def __init__(self):
diff --git "a/Solutions/\351\235\242\350\257\225\351\242\230 16.05. \351\230\266\344\271\230\345\260\276\346\225\260.md" "b/Solutions/\351\235\242\350\257\225\351\242\230 16.05. \351\230\266\344\271\230\345\260\276\346\225\260.md"
index d8298c12..c28581ac 100644
--- "a/Solutions/\351\235\242\350\257\225\351\242\230 16.05. \351\230\266\344\271\230\345\260\276\346\225\260.md"
+++ "b/Solutions/\351\235\242\350\257\225\351\242\230 16.05. \351\230\266\344\271\230\345\260\276\346\225\260.md"
@@ -17,7 +17,7 @@
## 代码
-```Python
+```python
class Solution:
def trailingZeroes(self, n: int) -> int:
count = 0
diff --git "a/Solutions/\351\235\242\350\257\225\351\242\230 16.26. \350\256\241\347\256\227\345\231\250.md" "b/Solutions/\351\235\242\350\257\225\351\242\230 16.26. \350\256\241\347\256\227\345\231\250.md"
index e27a1143..6f6ca980 100644
--- "a/Solutions/\351\235\242\350\257\225\351\242\230 16.26. \350\256\241\347\256\227\345\231\250.md"
+++ "b/Solutions/\351\235\242\350\257\225\351\242\230 16.26. \350\256\241\347\256\227\345\231\250.md"
@@ -28,7 +28,7 @@
## 代码
-```Python
+```python
class Solution:
def calculate(self, s: str) -> int:
size = len(s)
diff --git "a/Solutions/\351\235\242\350\257\225\351\242\230 17.06. 2\345\207\272\347\216\260\347\232\204\346\254\241\346\225\260.md" "b/Solutions/\351\235\242\350\257\225\351\242\230 17.06. 2\345\207\272\347\216\260\347\232\204\346\254\241\346\225\260.md"
index fa1649fd..57d3fb43 100644
--- "a/Solutions/\351\235\242\350\257\225\351\242\230 17.06. 2\345\207\272\347\216\260\347\232\204\346\254\241\346\225\260.md"
+++ "b/Solutions/\351\235\242\350\257\225\351\242\230 17.06. 2\345\207\272\347\216\260\347\232\204\346\254\241\346\225\260.md"
@@ -17,7 +17,7 @@
- 示例 1:
-```Python
+```python
输入: 25
输出: 9
解释: (2, 12, 20, 21, 22, 23, 24, 25)(注意 22 应该算作两次)
@@ -47,7 +47,7 @@
### 思路 1:代码
-```Python
+```python
class Solution:
def numberOf2sInRange(self, n: int) -> int:
# 将 n 转换为字符串 s
diff --git "a/Solutions/\351\235\242\350\257\225\351\242\230 17.14. \346\234\200\345\260\217K\344\270\252\346\225\260.md" "b/Solutions/\351\235\242\350\257\225\351\242\230 17.14. \346\234\200\345\260\217K\344\270\252\346\225\260.md"
index 7e1dce51..f5c1492c 100644
--- "a/Solutions/\351\235\242\350\257\225\351\242\230 17.14. \346\234\200\345\260\217K\344\270\252\346\225\260.md"
+++ "b/Solutions/\351\235\242\350\257\225\351\242\230 17.14. \346\234\200\345\260\217K\344\270\252\346\225\260.md"
@@ -23,7 +23,7 @@
## 代码
-```Python
+```python
class Solution:
def heapify(self, nums: [int], index: int, end: int):
left = index * 2 + 1
diff --git "a/Solutions/\351\235\242\350\257\225\351\242\230 17.15. \346\234\200\351\225\277\345\215\225\350\257\215.md" "b/Solutions/\351\235\242\350\257\225\351\242\230 17.15. \346\234\200\351\225\277\345\215\225\350\257\215.md"
index 4c18fb36..bf7e48d8 100644
--- "a/Solutions/\351\235\242\350\257\225\351\242\230 17.15. \346\234\200\351\225\277\345\215\225\350\257\215.md"
+++ "b/Solutions/\351\235\242\350\257\225\351\242\230 17.15. \346\234\200\351\225\277\345\215\225\350\257\215.md"
@@ -19,7 +19,7 @@
## 代码
-```Python
+```python
class Trie:
def __init__(self):
diff --git "a/Solutions/\351\235\242\350\257\225\351\242\230 17.17. \345\244\232\346\254\241\346\220\234\347\264\242.md" "b/Solutions/\351\235\242\350\257\225\351\242\230 17.17. \345\244\232\346\254\241\346\220\234\347\264\242.md"
index 24da1ab7..7415bd19 100644
--- "a/Solutions/\351\235\242\350\257\225\351\242\230 17.17. \345\244\232\346\254\241\346\220\234\347\264\242.md"
+++ "b/Solutions/\351\235\242\350\257\225\351\242\230 17.17. \345\244\232\346\254\241\346\220\234\347\264\242.md"
@@ -19,7 +19,7 @@
## 代码
-```Python
+```python
class Trie:
def __init__(self):