Timer is Running

Operations on PriorityQueue
##### Submissions: 4303   Accuracy: 80.12%   Difficulty: Medium   Marks: 4

Given N integers, your task is to add these elements to the PriorityQueue. Also, given M integers, the task is to check if the given element is present in the PriorityQueue or not.
If the element is present, then 1 is printed by the driver code, after that the max element of priority queue is printed. Then the driver code deletes the max element.
Note: Here the driver code has implemented the PriorityQueue as a max-heap.

Example:

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

Output:
1
5
1
4
1
3
-1
-1

Explanation:
After inserting given elements, when we find 1,
which is present, so 1 gets printed, and then the
top element of the PriorityQueue which is 5 gets
printed, and then it gets deleted. Similarly, when
element is not present, just -1 is printed.```

insert(PriorityQueue q, int k) : You just insert k into q.
find(PriorityQueue q, int k) : You return true if k is in q, else you return false.
delete(PriorityQueue q) : You delete the top element (which is also the max element) and return it.

Constraints:
1 <= N <= 103
1 <= M <= 103

#### ** For More Input/Output Examples Use 'Expected Output' option **

Author: Dhiman Mayank

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.