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,18 +6,18 @@ Author: timi (xisunyy@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 linear_search_array(nums, target):
""" 线性查找(数组) """
# 遍历数组
for i in range(len(nums)):
if nums[i] == target: # 找到目标元素,返回其索引
return i
return -1 # 未找到目标元素,返回 -1
""" 线性查找(链表) """
def linear_search_linkedlist(head, target):
""" 线性查找(链表) """
# 遍历链表
while head:
if head.val == target: # 找到目标结点,返回之