Microsoft interview question

The question was based on a heap