clueless coding // TODO: be smarter

LeetCode Reverse String: CPP Solution



TL;DR Code Solution


string reverseString(string s) {
    for (int i = 0; i < s.length() / 2; i++) {
        char temp = s[i];
        s[i] = s[s.length() - i - 1];
        s[s.length() - i - 1] = temp;
    }
    return s;
}