Skip to content · ⁨ข้ามไปยังเนื้อหา⁩

Reverse the word order · ⁨กลับลำดับคำ⁩

English

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 เป็นวิธีที่เรียบร้อยในการรวมพวกมัน

Log in or create account · ⁨เข้าสู่ระบบหรือสร้างบัญชี⁩

IGCSE, A-Level & AP