|
|
|
@ -4,11 +4,7 @@
|
|
|
|
|
|
|
|
|
|
package chapter_searching
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
//"fmt"
|
|
|
|
|
"github.com/krahets/hello-algo/pkg"
|
|
|
|
|
_ "github.com/krahets/hello-algo/pkg"
|
|
|
|
|
)
|
|
|
|
|
import . "github.com/krahets/hello-algo/pkg"
|
|
|
|
|
|
|
|
|
|
/* 哈希查找(数组) */
|
|
|
|
|
func hashingSearch(m map[int]int, target int) int {
|
|
|
|
@ -22,7 +18,7 @@ func hashingSearch(m map[int]int, target int) int {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* 哈希查找(链表) */
|
|
|
|
|
func hashingSearch1(m map[int]*pkg.ListNode, target int) *pkg.ListNode {
|
|
|
|
|
func hashingSearch1(m map[int]*ListNode, target int) *ListNode {
|
|
|
|
|
// 哈希表的 key: 目标结点值,value: 结点对象
|
|
|
|
|
// 若哈希表中无此 key ,返回 nil
|
|
|
|
|
if node, ok := m[target]; ok {
|
|
|
|
|