My C++ Solution


  • 0
    Q
    class Solution {
    public:
        string reverseString(string s) {
            int len = s.length();
            if(len<=1)
                return s;
            int i=0,j=len-1;
            while(i<j)
                swap(s[i++],s[j--]);
            return s;
        }
    };
    

Log in to reply
 

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