From 4d542be9d4fe8e64d45a4db34ddc537a26d265ad Mon Sep 17 00:00:00 2001 From: zhuoqinyue <64182179+zhuoqinyue@users.noreply.github.com> Date: Wed, 11 Jan 2023 14:13:16 +0800 Subject: [PATCH] Update codes/typescript/chapter_searching/hashing_search.ts Co-authored-by: Justin Tse --- codes/typescript/chapter_searching/hashing_search.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/codes/typescript/chapter_searching/hashing_search.ts b/codes/typescript/chapter_searching/hashing_search.ts index 6133942b7..7f93d7178 100644 --- a/codes/typescript/chapter_searching/hashing_search.ts +++ b/codes/typescript/chapter_searching/hashing_search.ts @@ -9,10 +9,10 @@ import ListNode from "../module/ListNode"; /* 哈希查找(数组) */ -function hashingSearch(map: Map, target: number) { +function hashingSearch(map: Map, target: number): number { // 哈希表的 key: 目标元素,value: 索引 // 若哈希表中无此 key ,返回 -1 - return map.has(target) ? map.get(target) : -1; + return map.has(target) ? map.get(target) as number : -1; } /* 哈希查找(链表) */