Reverse the word order · Inverter a ordem das palavras
Reverse the word order
Given a sentence of space-separated words, return the words in reverse order: the quick brown → brown quick the. Split on spaces with s.split(" "), then build the result from the last word to the first. A StringBuilder is the tidy way to join them.
Inverta a ordem das palavras
Dada uma frase de palavras separadas por espaços, retorne as palavras em ordem inversa: the quick brown → brown quick the. Separe nos espaços com s.split(" "), depois construa o resultado da última palavra para a primeira. Um StringBuilder é a maneira limpa de uni-las.
Complete reverseWords(String s) so it returns the space-separated words in reverse order. Example: the quick brown becomes brown quick the. · Complete reverseWords(String s) para que retorne as palavras separadas por espaço na ordem invertida. Exemplo: the quick brown torna-se brown quick the.
Click Run to see the output here. · Clique em Executar para ver a saída aqui.