C 3ms solution


  • 1
    char* reverseString(char* s) {
        int len = strlen(s);
        int a = len/2;
        char tmp;
        for(int i=0,j=len-1; i<a; i++,j--){
            tmp = s[i];
            s[i] = s[j];
            s[j] = tmp;
        }
        return s;
    }
    

Log in to reply
 

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