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

Method put

python/706_Design_HashMap.py:11–25  ·  view source on GitHub ↗

value will always be non-negative. :type key: int :type value: int :rtype: void

(self, key, value)

Source from the content-addressed store, hash-verified

9 self.nodes = [None] * self.size
10
11 def put(self, key, value):
12 """
13 value will always be non-negative.
14 :type key: int
15 :type value: int
16 :rtype: void
17 """
18 index = hash(key) % self.size
19 if self.nodes[index] is None:
20 self.nodes[index] = ListNode(-1, -1)
21 prev = find(self.nodes[index], key)
22 if prev.next is None:
23 prev.next = ListNode(key, value)
24 else:
25 prev.next.val = value
26
27 def get(self, key):
28 """

Callers

nothing calls this directly

Calls 2

findFunction · 0.85
ListNodeClass · 0.70

Tested by

no test coverage detected