MCPcopy
hub / github.com/HuberTRoy/leetCode / insert

Method insert

Design/InsertDeleteGetRandomO(1).py:80–93  ·  view source on GitHub ↗

Inserts a value to the set. Returns true if the set did not already contain the specified element. :type val: int :rtype: bool

(self, val)

Source from the content-addressed store, hash-verified

78 self.length = 0
79
80 def insert(self, val):
81 """
82 Inserts a value to the set. Returns true if the set did not already contain the specified element.
83 :type val: int
84 :rtype: bool
85 """
86 if self.data_dict.get(val) is not None:
87 return False
88
89 self.data_dict[val] = self.length
90 self.length += 1
91 self.data_list.append(val)
92
93 return True
94
95 def remove(self, val):
96 """

Callers

nothing calls this directly

Calls 1

getMethod · 0.80

Tested by

no test coverage detected