Solution 1 - XOR Cancellation
XOR every character code; paired characters cancel and leave the added character.
""" 0389.1 - Find the Difference - Solution 1 - XOR Cancellation """
class Solution:
def findTheDifference(self, s: str, t: str) -> str:
x = 0
for c in s + t:
x ^= ord(c)
return chr(x)
if __name__ == "__main__":
print(Solution().findTheDifference("abcd", "abcde")) # e