Solve sliding-window and heap problems | Amazon Coding Question