text of English letters, digits and spaces. A word is any unbroken run of non-space characters.
Return a string with the same words in reverse order, separated by exactly one space. The input may have spaces at the start, at the end, and several in a row between words; the answer must have no extra spaces.
If strings are mutable in your language, try to use only O(1) extra memory.text="keep calm and code" → 'code and calm keep'
text=" north wind " → 'wind north'
The spaces at the edges go away and the double space becomes a single one: wind north.
text="Room 42" → '42 Room'
Digits are part of a word too: 42 Room.
text consists of English letters, digits and spacestext contains at least one wordtext="keep calm and code"
'code and calm keep'
Run checks the first 3 tests in your browser. Submit checks all 4 tests on the server, hidden ones included.