Skip to content · ⁨Pular para o conteúdo⁩

Reverse the word order · ⁨Inverter a ordem das palavras⁩

English

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.

Português

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.

Log in or create account · ⁨Entrar ou criar conta⁩

IGCSE, A-Level & AP