Easy C Solution


  • 0
    A

    This problem remind me of a bitwise problem where you have as input an array each element has it's peer and only one is alone and you have to find this element, So the idea behind my solution is to concatenate these 2 strings and i got exactly the same problem:

    char findTheDifference(char* s, char* t) {
    char str[10000]; 
    char ret =0;
    int i = 0;
    
     memset(str,0,sizeof(str));
    strcat(str,s);
    strcat(str,t);
    
    for(i=0;str[i];i++)
    {
        ret = ret^str[i];
    }
    return ret;
    }

Log in to reply
 

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