This commit is contained in:
krahets
2023-03-03 02:46:12 +08:00
parent 122805bdc9
commit cf9d102ed5
24 changed files with 320 additions and 314 deletions
+2 -2
View File
@@ -49,8 +49,8 @@ comments: true
=== "Python"
```python title="linear_search.py"
""" 线性查找(数组) """
def linear_search_array(nums, target):
""" 线性查找(数组) """
# 遍历数组
for i in range(len(nums)):
if nums[i] == target: # 找到目标元素,返回其索引
@@ -206,8 +206,8 @@ comments: true
=== "Python"
```python title="linear_search.py"
""" 线性查找(链表) """
def linear_search_linkedlist(head, target):
""" 线性查找(链表) """
# 遍历链表
while head:
if head.val == target: # 找到目标结点,返回之