• + 2 comments

    Aha. I've come up with an O(nlogn) algorithm (or O(nloglogn) with dynamic data structures which I don't care to implement) that I'm going to try.