Update docs/chapter_searching/hashing_search.md

Co-authored-by: Justin Tse <xiefahit@gmail.com>
pull/187/head
zhuoqinyue 2 years ago committed by GitHub
parent 4d542be9d4
commit 9adc78a3fe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -80,10 +80,10 @@ comments: true
```typescript title="hashing_search.ts" ```typescript title="hashing_search.ts"
/* 哈希查找(数组) */ /* 哈希查找(数组) */
function hashingSearch(map: Map<number, number>, target: number) { function hashingSearch(map: Map<number, number>, target: number): number {
// 哈希表的 key: 目标元素value: 索引 // 哈希表的 key: 目标元素value: 索引
// 若哈希表中无此 key ,返回 -1 // 若哈希表中无此 key ,返回 -1
return map.has(target) ? map.get(target) : -1; return map.has(target) ? map.get(target) as number : -1;
} }
``` ```

Loading…
Cancel
Save