You are viewing a single comment's thread. Return to all comments →
C++:
int theLoveLetterMystery(string s) { int cnt = 0; int k = 0; int left_part = 0; int right_part = 0; while (k < int(s.size() / 2)) { left_part = int(s[k]); right_part = int(s[s.size() - k - 1]); while (left_part != right_part) { if (left_part < right_part) { cnt++; right_part -= 1; } else if (left_part > right_part) { cnt++; left_part -= 1; } } k++; } return cnt; }
Seems like cookies are disabled on this browser, please enable them to open this website
The Love-Letter Mystery
You are viewing a single comment's thread. Return to all comments →
C++: