Skip to content
C

Implement Max Heap

Mediumjavapythonccppjavascript

Implement a Max Heap that supports inserting a value, reading the maximum, and removing the maximum.

Input Format

The first line contains an integer Q. Each of the next Q lines is one of: insert X, getMax, extractMax.

Output Format

For each getMax print the current maximum (or -1 if empty). For each extractMax print the removed maximum (or -1 if empty). One value per line.

Input (stdin)

Output

Run your code to see output here...