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. · اضغط تشغيل لرؤية المخرجات هنا.