您的位置:首页 > 其它

344. Reverse String

2018-03-07 20:19 246 查看
Write a function that takes a string as input and returns the string reversed.Example:
Given s = "hello", return "olleh".class Solution {
public:
string reverseString(string s) {
int i = 0, j = s.length() - 1;
while(i < j){
swap(s[i], s[j]);
i++;
j--;
}
return s;
}
};
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: