Timer is Running

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.


1 2 3 4 5 2 3 1
1 3 2 9 10


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.

Your Task:
Your task is to complete the following functions:
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.

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.

Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.

to report an issue on this page.