Pergunta de entrevista da empresa Microsoft

Reverse the words in a sentence.

Respostas da entrevista

Sigiloso

5 de ago. de 2011

tokenize the sentence string by space and then store the tokens (which are now words) in an array. Use for loop to display the words in the array, starting at the last index of the array.

Sigiloso

5 de ago. de 2011

@java student: After you tokenize, you can switch the array elements in place (0th element goes to (length - 1)th, 1st element goes to (length - 2)th, and so on. This was the main part of the answer they were looking for.