from random import random
Initialize your data structure here.
def insert(self, val: int) -> bool:
Inserts a value to the set. Returns true if the set did not already contain the specified element.
def remove(self, val: int) -> bool:
Removes a value from the set. Returns true if the set contained the specified element.
self.data[self.arr[-1]] = i
self.arr[i] = self.arr[-1]
def getRandom(self) -> int:
Get a random element from the set.
return self.arr[int(random() * self.n)]
# Your RandomizedSet object will be instantiated and called as such:
# param_1 = obj.insert(val)
# param_2 = obj.remove(val)
# param_3 = obj.getRandom()