Simplest C++ Solution With Loop


  • 0
    M
    class Solution {
    public:
        string reverseString(string s) {
            for (int i = 0; i < s.size() / 2; ++i) swap(s[i], s[s.size() - i - 1]);
            return s;
        }
    };
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.