Solution in C


  • 0
    I

    char* reverseString(char* s) {
    int n = 0, i = 0;

    while(s[n] != '\0'){
        n++;
    }
    
    for(i = 0; i < n/2; i++){
        s[i] = s[i]^s[n-i-1];
        s[n-i-1] = s[i]^s[n-i-1];
        s[i] = s[i]^s[n-i-1];
        
    }
    
    return s;
    

    }


Log in to reply
 

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