RandomizedCollection data structure contain collection number possibly duplicate ie multiset it support insert remove specific element remove random elementImplement RandomizedCollection classrandomizedcollection Initializes RandomizedCollection objectbool insertint val Inserts item val multiset item present return true item present false otherwisebool removeint val Removes item val multiset present return true item present false note val multiple occurrence multiset remove themint getrandom return random element current multiset element the probability element return linearly relate number value multiset containsYou implement function class function work average O1 time complexityNote the test case generate getrandom call item RandomizedCollection Example 1inputrandomizedcollection insert insert insert getRandom remove getrandom 1 1 2 1 outputnull true false true 2 true 1explanationrandomizedcollection randomizedcollection new RandomizedCollectionrandomizedCollectioninsert1 return true collection contain 1 Inserts 1 collectionrandomizedcollectioninsert1 return false collection contain 1 Inserts 1 collection Collection contain 11randomizedcollectioninsert2 return true collection contain 2 Inserts 2 collection Collection contain 112randomizedcollectiongetrandom getrandom return 1 probability 23 return 2 probability 13randomizedcollectionremove1 return true collection contain 1 Removes 1 collection Collection contain 12randomizedcollectiongetrandom getrandom return 1 2 equally likely constraints231 val 231 1at 2 105 call total insert remove getrandomthere element datum structure getrandom call