MCPcopy Create free account
hub / github.com/neetcode-gh/leetcode / Put

Method Put

go/0706-design-hashmap.go:32–42  ·  view source on GitHub ↗
(key int, value int)

Source from the content-addressed store, hash-verified

30}
31
32func (this *MyHashMap) Put(key int, value int) {
33 cur := this.Array[this.hash(key)]
34 for cur.Next != nil {
35 if cur.Next.Key == key {
36 cur.Next.Val = value
37 return
38 }
39 cur = cur.Next
40 }
41 cur.Next = NewNode(key, value)
42}
43
44func (this *MyHashMap) Get(key int) int {
45 cur := this.Array[this.hash(key)]

Callers

nothing calls this directly

Calls 2

hashMethod · 0.95
NewNodeFunction · 0.70

Tested by

no test coverage detected