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.

العربية

عكس ترتيب الكلمات

بمعطى جملة من كلمات مفصولة بمسافات، أعد الكلمات بترتيب عكسي: the quick brown ← brown quick the. افصل على المسافات باستخدام s.split(" ")، ثم بنِّ النتيجة بدءًا من الكلمة الأخيرة إلى الأولى. يُعدّ StringBuilder الطريقة المرتبة لدمجها.

Log in or create account · ⁨تسجيل الدخول أو إنشاء حساب⁩

IGCSE, A-Level & AP