相关疑难解决方法(0)

反转字符串中单词的顺序

我有这个string s1 = "My name is X Y Z",我想扭转这些词的顺序s1 = "Z Y X is name My".

我可以使用额外的数组来做到这一点.我认为很难,但有可能在现场(不使用额外的数据结构)并且时间复杂度为O(n)吗?

string algorithm data-structures

68
推荐指数
4
解决办法
19万
查看次数

标签 统计

algorithm ×1

data-structures ×1

string ×1