3MS C SWAP solution.


  • 0
    H
    #define SWAP(a,b) {a^=b; b^=a; a^=b;} 
    char* reverseString(char* s) {
        for(int i = 0; ; i++)
        {
            if(s[i] == '\0')
            {
                for(int j = 0; j < i - j - 1; j++)
                {
                    SWAP(s[j], s[i-j-1]);
                }
                return s;
            }
        }
    }
    

Log in to reply
 

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