C simple solution


  • 0
    1

    '''
    char* reverseString(char* s) {
    int left = strlen(s);
    char *ret = malloc(left + 1);
    char *out = ret;
    int i = 0;
    for (i = 0; i < left; i++)
    {
    out[left - 1 - i] = s[i];
    }
    out[left] = 0;
    return ret;
    }
    '''


Log in to reply
 

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