Pergunta de entrevista da empresa X

Reverse all the words in a given sentence

Respostas da entrevista

Sigiloso

11 de jan. de 2013

Iterate through the sentence and push characters onto a stack until you hit a non-alphanumeric character. When that happens pop all values off the stack (barring it's not empty) - printing each as you go - and then print the non-alphanumeric character. Do this until you hit the end of the string. If you hit the end of the string and there are characters in the pop and print each until the stack is empty. O(n) time/space.

2

Sigiloso

11 de jan. de 2013

*characters in the stack