Example:
Given s = "hello", return "olleh".
Subscribe to see which companies asked this question
class Solution {
public:
string reverseString(string s) {
int len = s.length();
string r;
for(int i=0; i<len; i++)
{
//r.push_back(s[len-1-i]); //+ and push_back() function are both OK
r += s[len-1-i];
//r.append(s[len-1-i]);
}
return r;
}
};