C++ solution


  • 0
    J
    class Solution {
    public:
        string reverseString(string s) {
            int len = s.length();
            for(int i = 0; i < len / 2; i++)
            {
                char tmp = s[i];
                s[i] = s[len - 1 - i];
                s[len - 1 - i] = tmp;
            }
            return s;   
        }
    };
    

Log in to reply
 

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