Write a function that takes a string as input and returns the string reversed.
Example:
Given s = "hello", return "olleh".
Subscribe to see which companies asked this question
比较简单,想写个不一样的,所以用了string流,但还是写错了类型名字
ostringstream.
class Solution {
public:
string reverseString(string s) {
ostringstream s1;
for(int t= s.size()-1;t>=0;--t)
{
s1<<s[t];
}
return s1.str();
}
};