Domanda di colloquio di Amazon

Question about min/max heaps and optimizing runtime