Some words read the same backwards, like level and noon. Write same_both_ways(word): the starter already copies it into back; use reverse to turn back around, then compare it with word. Different capitals count as different; an empty word counts as the same.
same_both_ways("level")→Truesame_both_ways("hello")→Falsebool same_both_ways(const string &word)#include <algorithm>
#include <string>
using namespace std;
bool same_both_ways(const string &word) {
string back = word;
// your code here: reverse back
return back == word;
}
Run tries the examples. When they look right, Submit.