Solve the max in rolling window problem using a TreeMap, an O(nlgk) solution.