

‘SPECIAL_ARRAY’() is a function that initializes your array.
‘INSERT’( ‘VAL’ ) inserts the ‘VAL’ into the array and returns a boolean value. If ‘VAL’ is not present in the array before insertion, return ‘TRUE’, else return ‘FALSE’.
‘REMOVE’(‘VAL’) removes the ‘VAL ’from the array if present. This function would return a boolean value ‘TRUE’ if ‘VAL’ was present in the array before the deletion, else returns ‘FALSE’. If multiple occurrences of ‘VAL’ are present in the array, delete only one occurrence.
‘GET_RANDOM’( ) returns any random value of the array.
If the functions calls are as follows:
‘INSERT’(10).
‘INSERT’(20)’.
‘INSERT’(20)
‘REMOVE’(20).
‘GET_RANDOM()’
So, the answers for the calls are [‘TRUE’, ’TRUE’, ’FALSE’, ’TRUE’,10]. Another valid output of the
‘GET_RANDOM()’ function call is 20.
The first line of the input contains an integer, 'T,’ denoting the number of test cases.
The first line of each test case contains a single integer, 'N’, denoting the number of function calls.
The second line contains a list of ‘N’ function names.
The third line of each test case contains ‘N’ integers denoting the parameters passed in each function call. (Parameter value corresponding to any ‘GET_FUNCTION’() function is -1.)
For each test case, output the values returned by function calls as ‘TRUE’, ’FALSE’ or the returned number.
Print the output of each test case in a separate line.
You do not need to print anything. It has already been taken care of. Just implement the given function.
1 <= T <= 10
1 <= N <= 10000.
0 <= ‘VAL’ <= 10^6 .
Time limit: 1 sec
In this approach, we will implement this special array using a simple dynamic array.
In the insert function, we will search if the element is present in the array or not and insert the new element.
In the insert function, we will search if the element is present in the array or not, and if present, we will swap it with the last element of the array and remove the last element from the array.
In getRandom function, we will randomly select an index between 0 to (length of array -1), then return the value corresponding to that index.
In this approach, we will use the same ‘ARR’ array to store the values.To avoid the searching process, we will create a HashMap ‘INDICES’ which will store the indices of each value in an set. For examples INDICES[30] will store all the indices of ‘ARR’ which have a value of 30 in an unordered set. So, to check if the number is present or not, we can simply check it in O(1) by checking the size of INDICES[‘VAL’].