Write a function that takes a string as input and returns the string reversed.
Example:
Given s = "hello", return "olleh".
思路:
当然可以用双指针来做,不过最简单的还使用STL。
题解:
std::string reverseString(std::string s) {
std::string result;
std::copy(s.rbegin(), s.rend(), std::back_inserter(result));
return result;
}