Citadel interview question

Heap based question for techincal problem