Skip to content
C

Implement Min Heap

Mediumjavapythonccppjavascript

Implement a Min Heap that supports inserting a value, reading the minimum, and removing the minimum.

Input Format

The first line contains an integer Q. Each of the next Q lines is one of: insert X — add integer X getMin — report the minimum extractMin — remove and report the minimum

Output Format

For each getMin print the current minimum (or -1 if the heap is empty). For each extractMin print the removed minimum (or -1 if the heap is empty). One value per line.

Input (stdin)

Output

Run your code to see output here...