MCPcopy Index your code
hub / github.com/qiyuangong/leetcode / get

Method get

python/706_Design_HashMap.py:27–40  ·  view source on GitHub ↗

Returns the value to which the specified key is mapped, or -1 if this map contains no mapping for the key :type key: int :rtype: int

(self, key)

Source from the content-addressed store, hash-verified

25 prev.next.val = value
26
27 def get(self, key):
28 """
29 Returns the value to which the specified key is mapped, or -1 if this map contains no mapping for the key
30 :type key: int
31 :rtype: int
32 """
33 index = hash(key) % self.size
34 if self.nodes[index] is None:
35 return -1
36 prev = find(self.nodes[index], key)
37 if prev.next is None:
38 return -1
39 else:
40 return prev.next.val
41
42 def remove(self, key):
43 """

Callers

nothing calls this directly

Calls 1

findFunction · 0.85

Tested by

no test coverage detected