"""
389. Find the Difference

Given two strings s and t which consist of only lowercase letters.

String t is generated by random shuffling string s and then add one more letter at a random position.

Find the letter that was added in t.

Example:

Input:
s = "abcd"
t = "abcde"

Output:
e

Explanation:
'e' is the letter that was added.
"""
# MOWN
from collections import defaultdict


class Solution(object):
    def findTheDifference(self, s, t):
        """
        :type s: str
        :type t: str
        :rtype: str
        """
        mapr = defaultdict(int)
        for i in s:
            mapr[i] += 1
        for i in t:
            mapr[i] -= 1

        return [key for key, value in mapr.iteritems() if value][0]


# LUP
from collections import Counter


class Solution(object):
    def findTheDifference(self, s, t):
        return list(Counter(t) - Counter(s))[0]


# LUP2
class Solution(object):
    def findTheDifference(self, s, t):
        return chr(reduce(lambda x, y: x ^ y, map(ord, s + t)))