Queue Operations
Easy Accuracy: 77.52% Submissions: 4756 Points: 2

Here, we will learn operations on queues.

Given N integers, the task is to insert those elements in the queue. Also, given M integers, task is to find the frequency of each number in the Queue.

Example:

Input:
8
1 2 3 4 5 2 3 1
5
1 3 2 9 10

Output:
2
2
2
-1
-1

Explanation:
After inserting 1, 2, 3, 4, 5, 2, 3, 1 into the queue, 
frequency of 1 is 2, 3 is 2, 2 is 2, 9 is -1 and 10 is 
-1 (since, 9 and 10 is not there in the queue).

Your Task:
Your task is to complete the functions insert() and findFrequency() which inserts the element into the queue and find the count of occurences of element in the queue respectively.

Constraints:
1 <= N <= 103
1 <= M <= 103
1 <= Elements of Queue <= 106

to report an issue on this page.

Editorial

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Yes

All Submissions

My Submissions:

Login to access your submissions.