Domanda di colloquio di Google

simple algorithm question about ques and stacks