leetcode-389-easy

Find the Difference
思路一: xor 两个字符串

public char findTheDifference(String s, String t) {
    char result = 0;

    for (int i = 0; i < s.length(); i++) {
        result ^= s.charAt(i);
    }

    for (int j = 0; j < t.length(); j++) {
        result ^= t.charAt(j);
    }

    return result;
}
posted @ 2022-10-19 07:37  iyiluo  阅读(28)  评论(0)    收藏  举报