Reverse the word order · Обратный порядок слов
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.
Реверс порядка слов
Дана фраза со словами, разделёнными пробелами. Верните слова в обратном порядке: the quick brown → brown quick the. Разбейте строку на части пробелами с помощью s.split(" "), а затем соберите результат от последнего слова к первому. Для аккуратного объединения слов удобно использовать StringBuilder.
Complete reverseWords(String s) so it returns the space-separated words in reverse order. Example: the quick brown becomes brown quick the. · Заполните reverseWords(String s) так, чтобы он возвращал слова, разделённые пробелами, в обратном порядке. Пример: the quick brown превращается в brown quick the.
Click Run to see the output here. · Нажмите Запустить, чтобы увидеть результат здесь.