mirror of
https://github.com/krahets/hello-algo.git
synced 2026-08-17 06:00:58 +00:00
build
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user