MathWorks interview question

algorithm problem with deque method