Amazon interview question

Leetcode question with priority queues