MCPcopy
hub / github.com/qiyuangong/leetcode / remove

Method remove

python/706_Design_HashMap.py:42–54  ·  view source on GitHub ↗

Removes the mapping of the specified value key if this map contains a mapping for the key :type key: int :rtype: void

(self, key)

Source from the content-addressed store, hash-verified

40 return prev.next.val
41
42 def remove(self, key):
43 """
44 Removes the mapping of the specified value key if this map contains a mapping for the key
45 :type key: int
46 :rtype: void
47 """
48 index = hash(key) % self.size
49 if self.nodes[index] is None:
50 return
51 prev = find(self.nodes[index], key)
52 if prev.next is None:
53 return
54 prev.next = prev.next.next
55
56
57def find(bucket, key):

Callers 6

longestConsecutiveMethod · 0.45
updateQueueMethod · 0.45
putMethod · 0.45
hasCycleMethod · 0.45
thirdMaxMethod · 0.45

Calls 1

findFunction · 0.85

Tested by

no test coverage detected