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.

geetyadav | 82 |

yashrana1 | 74 |

AdityaRaj9 | 73 |

abuexshaitan | 56 |

Shashi Bhushan | 52 |

abducodes | 837 |

harshtyagi36 | 399 |

sandipbhaumik | 321 |

Akhil varma | 314 |

vamsikrishna55 | 304 |

blackshadows | 5331 |

Ibrahim Nash | 5219 |

akhayrutdinov | 5111 |

mb1973 | 4929 |

Quandray | 4567 |

Login to report an issue on this page.