C solution


  • 0
    J
    char* reverseString(char* s) 
    {
        int n = strlen (s);
        int i;
        char t;
        for (i = 0;i <= n/2-1;i ++)
        {
            t = s[i];
            s[i] = s[n-1-i];
            s[n-1-i] = t;
        }
        return s;
    }
    

    Be similar to Bubble Sort


Log in to reply
 

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