Finish the stack and queue problem