Update code style for Python

This commit is contained in:
krahets
2023-03-03 03:07:22 +08:00
parent 7e9e6b000c
commit 7c501140f0
45 changed files with 274 additions and 266 deletions

View File

@ -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)