mirror of
https://github.com/krahets/hello-algo.git
synced 2024-12-25 12:36:30 +08:00
update the doc
This commit is contained in:
parent
01a6fcef20
commit
5cfcba1eb9
1 changed files with 25 additions and 5 deletions
|
@ -68,13 +68,23 @@ comments: true
|
||||||
=== "JavaScript"
|
=== "JavaScript"
|
||||||
|
|
||||||
```js title="hashing_search.js"
|
```js title="hashing_search.js"
|
||||||
|
/* 哈希查找(数组) */
|
||||||
|
function hashingSearch(map, target) {
|
||||||
|
// 哈希表的 key: 目标元素,value: 索引
|
||||||
|
// 若哈希表中无此 key ,返回 -1
|
||||||
|
return map.has(target) ? map.get(target) : -1;
|
||||||
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
=== "TypeScript"
|
=== "TypeScript"
|
||||||
|
|
||||||
```typescript title="hashing_search.ts"
|
```typescript title="hashing_search.ts"
|
||||||
|
/* 哈希查找(数组) */
|
||||||
|
function hashingSearch(map: Map<number, number>, target: number) {
|
||||||
|
// 哈希表的 key: 目标元素,value: 索引
|
||||||
|
// 若哈希表中无此 key ,返回 -1
|
||||||
|
return map.has(target) ? map.get(target) : -1;
|
||||||
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
=== "C"
|
=== "C"
|
||||||
|
@ -145,19 +155,29 @@ comments: true
|
||||||
} else {
|
} else {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
=== "JavaScript"
|
=== "JavaScript"
|
||||||
|
|
||||||
```js title="hashing_search.js"
|
```js title="hashing_search.js"
|
||||||
|
/* 哈希查找(链表) */
|
||||||
|
function hashingSearch1(map, target) {
|
||||||
|
// 哈希表的 key: 目标结点值,value: 结点对象
|
||||||
|
// 若哈希表中无此 key ,返回 null
|
||||||
|
return map.has(target) ? map.get(target) : null;
|
||||||
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
=== "TypeScript"
|
=== "TypeScript"
|
||||||
|
|
||||||
```typescript title="hashing_search.ts"
|
```typescript title="hashing_search.ts"
|
||||||
|
/* 哈希查找(链表) */
|
||||||
|
function hashingSearch1(map: Map<number, any>, target: number) {
|
||||||
|
// 哈希表的 key: 目标结点值,value: 结点对象
|
||||||
|
// 若哈希表中无此 key ,返回 null
|
||||||
|
return map.has(target) ? map.get(target) : null;
|
||||||
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
=== "C"
|
=== "C"
|
||||||
|
|
Loading…
Reference in a new issue