Problem title
Difficulty
Avg time to solve

Decode Ways
Moderate
15 mins
Capture region
Moderate
10 mins
Largest Distance Between Two Nodes In A Tree
Moderate
15 mins
Shortest Alternating Path
Moderate
10 mins
Possible Words From A Phone Number
Hard
55 mins
Binary Tree From Bracket
Easy
10 mins
Path Sum lll
Hard
50 mins
Deleting and Adding the last node
Easy
10 mins
Queue Using Two Stacks
Easy
15 mins
2’s Complement
Easy
20 mins
5

# Implement a priority queue

Difficulty: MEDIUM

Problem Statement

#### Note:

``````There are four types of queries.

Type 1: push( x ) push element ‘x’ into queue.

Type 2: pop( ) delete the largest element from the queue, if the queue is empty then do nothing.

Type 3: getMaxElement( ) return largest element , if queue is empty return -1;

Type 4: isEmpty( ) return ‘1’ if queue is empty, otherwise return ‘0’.
``````
##### Input Format:
``````First-line will contain ‘Q’, the number of queries. Then the queries follow.

Each query has at least one integer representing the type of query. In the case of type 1, you have space-separated integer X.
``````
##### Output Format:
``````For each query of type 3 output an integer value in the newline.
``````
##### Note:
``````You have to complete the function only.
``````
##### Constraints:
``````1 <= Q <= 100
1 <= X <= 10 ^ 9

Time limit: 1 sec.
``````
##### Sample Input 1:
``````4
1 2
1 1
3
4
``````
##### Sample Output 1:
``````2
False
``````
##### Explanation:
``````After query 1, queue = {2}
After query 2, queue = {2, 1}.
After query 3, output the maximum number from queue i.e 2.
After query 4, Since queue= { 2 }, not empty, output “False”.
``````
##### Sample Input 2:
``````5
1 2
2
3
1 5
3
``````
##### Sample Output 2:
``````-1
5
``````
##### Explanation :
``````After query 1, queue = {2}
After query 2, queue = {  }
After query 3, Since the queue is empty, the output is -1.
After query 4, queue = { 5 }
After query 5, output the maximum number from queue i.e 5
``````
Console