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

Method put

python/0706-design-hashmap.py:14–21  ·  view source on GitHub ↗
(self, key: int, value: int)

Source from the content-addressed store, hash-verified

12 return key % len(self.map)
13
14 def put(self, key: int, value: int) -> None:
15 cur = self.map[self.hashcode(key)]
16 while cur.next:
17 if cur.next.key == key:
18 cur.next.val = value
19 return
20 cur = cur.next
21 cur.next = ListNode(key, value)
22
23 def get(self, key: int) -> int:
24 cur = self.map[self.hashcode(key)].next

Callers

nothing calls this directly

Calls 2

hashcodeMethod · 0.95
ListNodeClass · 0.70

Tested by

no test coverage detected