Question Approach I used the editorial because my solution (using priority queue (min-heap)) kept on failing some test cases.