Given N integers, your task is to add these elements to the PriorityQueue. Also, given M integers, the task is to check if element is present in PriorityQueue. If present, print 1 and return the max element of priority queue, and then delete the max element. If not present, print -1.
First line of testcas contains number of testcases T. For each testcase, there will be 4 lines. First line contains N, number of elements to be inserted into the Priority Queue. Second line contains N positive integers separated by space. Third line contains M, fourth line contains M positive integers.
For each testcase, print "1" and max element in newlines if element to be found is present in the PriorityQueue, else print "-1".
Your task is to complete the functions insert(), find(), and delete(), such that it adds, find and delete the elements from the queue respectively.
1 <= T <= 100
1 <= N <= 103
1 <= M <= 103
1 2 3 4 5 2 3 1
1 3 2 9 10
Testcase 1: After inserting given elements, when we find 1, which is present, so we print 1, and then we print the top element of the PriorityQueue which is 5, and delete it. Similarly, when element is not present, just print "-1".
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.