X Interview Question

Moving window sorting LC question.