You are given queries. Each query is of the form two integers described below:
- : Insert x in your data structure.
- : Delete one occurence of y from your data structure, if present.
- : Check if any integer is present whose frequency is exactly . If yes, print 1 else 0.
The queries are given in the form of a 2-D array of size where contains the operation, and contains the data element.
Complete the freqQuery function in the editor below.
freqQuery has the following parameter(s):
int queries[q]: a 2-d array of integers
- int: the results of queries of type
The first line contains of an integer , the number of queries.
Each of the next lines contains two space-separated integers, and .
Sample Input 0
81 51 63 21 101 101 62 53 2
Sample Output 0
For the first query of type , there is no integer whose frequency is (). So answer is .
For the second query of type , there are two integers in whose frequency is (integers = and ). So, the answer is .
Sample Input 1
43 42 10031 163 1
Sample Output 1
For the first query of type , there is no integer of frequency . The answer is .
For the second query of type , there is one integer, of frequency so the answer is .
Sample Input 2
101 32 33 21 41 51 51 43 22 43 2
Sample Output 2
When the first output query is run, the array is empty. We insert two 's and two 's before the second output query, so there are two instances of elements occurring twice. We delete a and run the same query. Now only the instances of satisfy the query.