Add Python code (Chapter of searching)
to the docs.
This commit is contained in:
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user