C语言 | Leetcode C语言题解之第389题找不同

题目:

C语言 | Leetcode C语言题解之第389题找不同_第1张图片

题解:

char findTheDifference(char* s, char* t) {
    int n = strlen(s), m = strlen(t);
    int ret = 0;
    for (int i = 0; i < n; i++) {
        ret ^= s[i];
    }
    for (int i = 0; i < m; i++) {
        ret ^= t[i];
    }
    return ret;
}

你可能感兴趣的:(分享,C语言,Leetcode,题解)