【LeetCode & 劍指offer刷題】字符串題3:Reverse String
阿新 • • 發佈:2019-01-05
form rgba public leet 劍指offer article span 微軟雅黑 ali
while(i<j)
{
swap(s[i++],s[j--]);
}
return s;
}
};*/
class Solution
{
public:
string reverseString(string s)
{
reverse(s.begin(), s.end());
return s;
}
};
【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;
【LeetCode & 劍指offer刷題】字符串題3:Reverse String