给定一个形成单词句子的字符数组,给出一个有效的算法来反转其中单词(而不是字符)的顺序.
示例输入和输出:
>>> reverse_words("this is a string") 'string a is this'
它应该是O(N)时间和O(1)空间(split()并且不允许推入/弹出堆栈).
split()
这个难题来自这里.
language-agnostic puzzle algorithm reverse
algorithm ×1
language-agnostic ×1
puzzle ×1
reverse ×1