C solution 0ms.


  • 0
    C

    char findTheDifference(char* s, char* t) {
    int sum=0;
    int i=0;
    while(s[i]!='\0')sum+=t[i]-s[i++];
    return sum+t[i];
    }

    char findTheDifference(char* s, char* t) {
    char c = t[0];
    int i=0;
    while(s[i])c=c^s[i]^t[++i];
    return c;
    }


Log in to reply
 

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