mirror of
https://github.com/krahets/hello-algo.git
synced 2025-07-23 01:10:06 +08:00
Update code style for Python
This commit is contained in:
@ -6,10 +6,10 @@ Author: Krahets (krahets@163.com)
|
||||
|
||||
import sys, os.path as osp
|
||||
sys.path.append(osp.dirname(osp.dirname(osp.abspath(__file__))))
|
||||
from include import *
|
||||
from modules import *
|
||||
|
||||
""" 方法一:暴力枚举 """
|
||||
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)):
|
||||
@ -17,8 +17,8 @@ def two_sum_brute_force(nums: List[int], target: int) -> List[int]:
|
||||
return i, j
|
||||
return []
|
||||
|
||||
""" 方法二:辅助哈希表 """
|
||||
def two_sum_hash_table(nums: List[int], target: int) -> List[int]:
|
||||
""" 方法二:辅助哈希表 """
|
||||
# 辅助哈希表,空间复杂度 O(n)
|
||||
dic = {}
|
||||
# 单层循环,时间复杂度 O(n)
|
||||
|
Reference in New Issue
Block a user