MathWorks Interview Question

algorithm problem with deque method