Solving moving window maximum problem using a heap