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
简单的字节倒转,怎么做都行。。我用栈
class Solution {
public:
string reverseString(string s) {
stack
for(int i = 0;i< s.length();i++)
{
sum.push(s[i]);
}
string temp;
for(int i = 0;i < s.length();i++)
{
temp = temp + sum.top();
sum.pop();
}
return temp;
}
};