1
Reverse a String
Problem Solving
string s = "hello";
reverse(s.begin(), s.end());
cout << s; // olleh
string s = "hello";
int i = 0, j = s.size() - 1;
while(i < j){
swap(s[i], s[j]);
i++; j--;
}
Note: reverse() needs #include <algorithm>.