344. Reverse String
Write a function that takes a string as input and returns the string reversed.
Example:
Given s = "hello", return "olleh".
class Solution {
public:
string reverseString(string s) {
int n=s.size();
int i=0;
int j=n-1;
while(i<=j) {
if (s[i] != s[j])
swap(s[i], s[j]);
i++;
j--;
}
return s;
}
};