Apple Interview Question

8 Queue problem