mirror of
https://github.com/krahets/hello-algo.git
synced 2025-07-25 11:13:38 +08:00
1. Add the building util of Python
for the markdown docs. 2. Update the deploy.sh
This commit is contained in:
17
docs/chapter_searching/linear_search.md
Normal file → Executable file
17
docs/chapter_searching/linear_search.md
Normal file → Executable file
@ -47,13 +47,7 @@ comments: true
|
||||
=== "Python"
|
||||
|
||||
```python title="linear_search.py"
|
||||
""" 线性查找(数组) """
|
||||
def linear_search_array(nums, target):
|
||||
# 遍历数组
|
||||
for i in range(len(nums)):
|
||||
if nums[i] == target: # 找到目标元素,返回其索引
|
||||
return i
|
||||
return -1 # 未找到目标元素,返回 -1
|
||||
[class]{}-[func]{linear_search_array}
|
||||
```
|
||||
|
||||
=== "Go"
|
||||
@ -195,14 +189,7 @@ comments: true
|
||||
=== "Python"
|
||||
|
||||
```python title="linear_search.py"
|
||||
""" 线性查找(链表) """
|
||||
def linear_search_linkedlist(head, target):
|
||||
# 遍历链表
|
||||
while head:
|
||||
if head.val == target: # 找到目标结点,返回之
|
||||
return head
|
||||
head = head.next
|
||||
return None # 未找到目标结点,返回 None
|
||||
[class]{}-[func]{linear_search_linkedlist}
|
||||
```
|
||||
|
||||
=== "Go"
|
||||
|
Reference in New Issue
Block a user