Task Manager (Priority Queue)

PHP Hard 8 views
Back to Questions

Problem Description

Commands: ADD name p, POP. POP removes and prints the task with highest priority; if tie, the one added earlier. If empty, print EMPTY.

Input Format

First line q. Next q lines.

Output Format

Outputs for POP.

Sample Test Case

Input:
7 POP ADD clean 2 ADD build 5 ADD test 5 POP POP POP
Output:
EMPTY build test clean

Constraints

q

Solutions (0)

No solutions submitted yet. Be the first!

Discussion (0)

No comments yet. Start the discussion!

Prev