# 389. Find the Difference """ given two strings 's' and 't'. string 't' is generated by random shuffling string 's' and then add one more letter at a random position. return the letter that was added to 't'. """ class Solution(object): def findTheDifference(self, s, t): ans = 0 for i in s: ans ^= ord(i) for i in t: ans ^= ord(i) return chr(ans) if __name__ == "__main__": obj = Solution() print(obj.findTheDifference("abcd", "abcde")) # expect: e print(obj.findTheDifference("", "y")) # expect: y