Priority Queue

Implement a priority queue where elements are dequeued based on their priority rather than insertion order.

Asked in frontend interviews at Google, Amazon, Microsoft and 1 more