This commit is contained in:
krahets
2023-04-09 05:12:22 +08:00
parent 01d05cc1f0
commit 37f11aff68
27 changed files with 265 additions and 248 deletions
@@ -66,7 +66,7 @@ comments: true
```python title="leetcode_two_sum.py"
def two_sum_brute_force(nums: list[int], target: int) -> list[int]:
""" 方法一:暴力枚举 """
"""方法一:暴力枚举"""
# 两层循环,时间复杂度 O(n^2)
for i in range(len(nums) - 1):
for j in range(i + 1, len(nums)):
@@ -243,7 +243,7 @@ comments: true
```python title="leetcode_two_sum.py"
def two_sum_hash_table(nums: list[int], target: int) -> list[int]:
""" 方法二:辅助哈希表 """
"""方法二:辅助哈希表"""
# 辅助哈希表,空间复杂度 O(n)
dic = {}
# 单层循环,时间复杂度 O(n)