Add Python code (Chapter of searching)

to the docs.
This commit is contained in:
Yudong Jin
2022-12-04 01:43:58 +08:00
parent e5563b3964
commit 8e34be0641
6 changed files with 106 additions and 51 deletions

View File

@@ -43,7 +43,11 @@ comments: true
=== "Python"
```python title="hashing_search.py"
""" 哈希查找(数组) """
def hashing_search(mapp, target):
# 哈希表的 key: 目标元素value: 索引
# 若哈希表中无此 key ,返回 -1
return mapp.get(target, -1)
```
=== "Go"
@@ -107,7 +111,11 @@ comments: true
=== "Python"
```python title="hashing_search.py"
""" 哈希查找(链表) """
def hashing_search1(mapp, target):
# 哈希表的 key: 目标元素value: 结点对象
# 若哈希表中无此 key ,返回 -1
return mapp.get(target, -1)
```
=== "Go"