Oracle Interview Question

a leetcode medium problem using heap