[EPIJ v 1.6.1 Problem 14.4]
I’ve implemented an O(n log n) time solution that uses sorting and PriorityQueue. I’d like to know if a solution is possible without using PriorityQueue, while still maintaining the same time bound.
Easier approach will be using BST as whatever priority queue can do, BST can do as well.
Cool. Thanks for the advice!
Follow up question - Is a solution possible without BST, PriorityQueue, or other such data structure?
It is possible by solving this by sorting.
Thanks @tsunghsienlee. I was able to devise a solution with just sorting.