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) {
if(s == "") return s;
for(int i = 0, j = s.size()-1; i < j; i++, j--) {
char ch = s[i];
s[i] = s[j];
s[j] = ch;
}
return s;
}
}