You are viewing a single comment's thread. Return to all comments →
Good answer. But if you want to reflect how the problem is worded then you can create the reversed string R pretty easily too:
R
void areYouFunny(string& S) { string R(S.rbegin(), S.rend()); bool isFunny = true; for (int i = 1; i < S.length() && isFunny; i++) { isFunny = abs(S[i] - S[i-1]) == abs(R[i] - R[i-1]); } cout << (isFunny ? "Funny" : "Not Funny") << endl; }
Seems like cookies are disabled on this browser, please enable them to open this website
Funny String
You are viewing a single comment's thread. Return to all comments →
Good answer. But if you want to reflect how the problem is worded then you can create the reversed string
R
pretty easily too: