我有这个string s1 = "My name is X Y Z",我想扭转这些词的顺序s1 = "Z Y X is name My".
string s1 = "My name is X Y Z"
s1 = "Z Y X is name My"
我可以使用额外的数组来做到这一点.我认为很难,但有可能在现场(不使用额外的数据结构)并且时间复杂度为O(n)吗?
string algorithm data-structures
algorithm ×1
data-structures ×1
string ×1