Problem Statement :
You are given q queries. Each query is of the form two integers described below:
- 1 x: Insert x in your data structure.
- 2 y: Delete one occurence of y from your data structure, if present.
- 3 z: Check if any integer is present whose frequency is exactly z . If yes, print 1 else 0.
The queries are given in the form of a 2-D array querries of size q where queries[i] contains the operation, and queries[i] contains the data element. For example, you are given array
queries = [ (1,1), (2,2), (3,2), (1,1), (1,1) , (2,1), (3,2) ] . The results of each operation are:
Operation Array Output
Return an array with the output: [0, 1] .
Complete the freqQuery function in the editor below. It must return an array of integers where each element is a 1 if there is at least one element value with the queried number of occurrences in the current array, or 0 if there is not.
freqQuery has the following parameter(s):
queries: a 2-d array of integers
The first line contains of an integer q, the number of queries.
Each of the next q lines contains two integers denoting the 2-d array queries.
1 <= q <= 10^5
1 <= x, y, z <= 10^9
1 <= queries[i] <= 10^9
Return an integer array consisting of all the outputs of queries of type 3.