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. · 実行ボタンをクリックして出力を確認してください。