Associated Course(s):
Fork Java

*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.

**Input Format:**

First line of input contains number of testcases **T**. For each testcase, there will be four lines. First line contains N, second line contains N integers separated by space. Third line contains M, next line contains M integers separated.

**Output Format:**

For each testcase, print the frequency of given elements.

**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 <= T <= 100

1 <= N <= 10^{3}

1 <= M <= 10^{3}

1 <= Elements of Queue <= 10^{6}

**Example:
Input:**

1

8

1 2 3 4 5 2 3 1

5

1 3 2 9 10

2

2

2

-1

-1

**Explanation:
Testcase 1: **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).

If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.

hardikJain5 | 258 |

CodeBuddy | 250 |

bhatabhi554 | 232 |

Akkki111 | 197 |

clone | 174 |

KshatriyaYash | 1932 |

nikhil_sojan | 1374 |

lonecoder | 1236 |

SumitSingh27 | 1127 |

mazumderrohit8 | 1124 |

blackshadows | 5327 |

Ibrahim Nash | 5219 |

akhayrutdinov | 5111 |

mb1973 | 4591 |

Quandray | 4444 |

Login to report an issue on this page.