XOR in Leetcode string or character
Read this first
This visual explanation explains really well
Explanation
So a XOR a becomes 0 because you know 1^1 = 0 (exclusive OR).
So when you want to find the extra character in t that s does not have, c ^= s, c^= t will rearrange itself to c ^= 5^5 ^ 1^1 ^ 2^2 ^4 which XOR with itself gets cancelled out, leaving that extra character behind.