[Problem 15.6 in EPIJ v 1.6.1]
I have an idea for a solution that uses PriorityQueue for time of O(n log k) and space O(k). I also have another idea that uses an O(k log k) sort for total time of O(n k log k). Both times simplify to O(n) for k = 3.
But the problem is in the Binary Search Tree chapter, which would imply that the solution should use binary search tree, not priority queue, or sort.
Does the “correct” solution actually use a binary search tree? I visually scanned over it super quickly (so as not to give the solution away to myself), and didn’t notice anything that seemed related to BST.