chars holding a phrase whose words are separated by exactly one space, with no spaces at the start or the end. A word is an unbroken run of non-space characters.
Put the words in reverse order; each word itself still reads the same. Return the list with the words reversed.
Try not to build an extra list: rearrange the characters inside chars itself with O(1) memory.chars=['g', 'o', ' ', 'f', 'a', 's', 't'] → ['f', 'a', 's', 't', ' ', 'g', 'o']
The words go and fast swap: the list becomes ['f', 'a', 's', 't', ' ', 'g', 'o'].
chars=['A', ' ', 'b', ' ', '7'] → ['7', ' ', 'b', ' ', 'A']
The result is ['7', ' ', 'b', ' ', 'A'].
chars=['o', 'k'] → ['o', 'k']
There is only one word, so the list stays the same.
chars[i] is an English letter, a digit or a spacechars=['g', 'o', ' ', 'f', 'a', 's', 't']
['f', 'a', 's', 't', ' ', 'g', 'o']
Run checks the first 3 tests in your browser. Submit checks all 32 tests on the server, hidden ones included.