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.
กลับหัวลำดับคำ
เมื่อได้รับประโยคที่มีคำแยกด้วยช่องว่าง, คืนคำใน reverse order: the quick brown → brown quick the. Split ด้วยช่องว่างด้วย s.split(" "), แล้วสร้างผลลัพธ์จากคำสุดท้ายไปคำแรก A 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. · คลิก Run เพื่อดูผลลัพธ์ที่นี่