Appian interview question

leetcode type technical question on heaps