Reverse the word order · Balik urutan kata
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.
Balik urutan kata
Diberikan kalimat dengan kata-kata terpisah spasi, kembalikan kata-kata dalam urutan terbalik: the quick brown → brown quick the. Pisahkan pada spasi dengan s.split(" "), lalu bangun hasil dari kata terakhir ke pertama. Sebuah StringBuilder adalah cara rapi untuk menggabungkan mereka.
Complete reverseWords(String s) so it returns the space-separated words in reverse order. Example: the quick brown becomes brown quick the. · Lengkapi reverseWords(String s) agar mengembalikan kata-kata yang dipisahkan spasi dalam urutan terbalik. Contoh: the quick brown menjadi brown quick the.
Click Run to see the output here. · Klik Jalankan untuk melihat output di sini.