MCPcopy Create free account
hub / github.com/HuberTRoy/leetCode / getRandom

Method getRandom

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

Get a random element from the set. :rtype: int

(self)

Source from the content-addressed store, hash-verified

115 return False
116
117 def getRandom(self):
118 """
119 Get a random element from the set.
120 :rtype: int
121 """
122
123 return self.data_list[random.randint(0, self.length-1)]
124
125
126# Your RandomizedSet object will be instantiated and called as such:

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected