Reverse the word order · Inverser l'ordre des mots
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.
Inverser l'ordre des mots
Étant donné une phrase de mots séparés par des espaces, retournez les mots dans l'ordre inverse : the quick brown → brown quick the. Séparez sur les espaces avec s.split(" "), puis construisez le résultat du dernier mot au premier. Un StringBuilder est la façon propre de les joindre.
Complete reverseWords(String s) so it returns the space-separated words in reverse order. Example: the quick brown becomes brown quick the. · Complétez reverseWords(String s) pour qu'il retourne les mots séparés par des espaces dans l'ordre inverse. Exemple : the quick brown devient brown quick the.
Click Run to see the output here. · Cliquez sur Exécuter pour voir le résultat ici.