【LeetCode & 剑指offer 刷题笔记】目录(持续更新中...)
Reverse String
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;
int j = s.size() - 1;
while(i<j)
{
swap(s[i++],s[j--]);
}
return s;
}
};*/
class
Solution
{
public
:
string reverseString
(
string s
)
{
reverse
(
s
.
begin
(),
s
.
end
());
return
s
;
}
};