class RandomizedCollection:
def __init__(self):
"""
Initialize your data structure here.
"""
self.l = list()
def insert(self, val: int) -> bool:
"""
Inserts a value to the collection. Returns true if the collection did not already contain the specified element.
"""
b = val in self.l
self.l.append(val)
return b
def remove(self, val: int) -> bool:
"""
Removes a value from the collection. Returns true if the collection contained the specified element.
"""
b = val in self.l
if b:
self.l.remove(val)
return b
def getRandom(self) -> int:
"""
Get a random element from the collection.
"""
from random import choice
return choice(self.l)
# Your RandomizedCollection object will be instantiated and called as such:
# obj = RandomizedCollection()
# param_1 = obj.insert(val)
# param_2 = obj.remove(val)
# param_3 = obj.getRandom()