Pregunta de entrevista de MathWorks

algorithm problem with deque method