c++ solution


  • 0
    P

    In place string reverse

    class Solution {
    public:
        string reverseString(string s) {
            for(int i=0,j=s.size()-1;i<j;i++,j--){
                char temp = s[i];
                s[i] = s[j];
                s[j] = temp;
            }
            return s;
        }
    };
    

Log in to reply
 

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