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. · לחץ על הרץ כדי לראות את התוצא כאן.