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.

Difficulty: introductory

Starter code:

class Solution:
    def findTheDifference(self, s: str, t: str) -> str:
        

Solutions:
class Solution:
     def findTheDifference(self, s, t):
         """
         :type s: str
         :type t: str
         :rtype: str
         """
         sums=sum([ord(i) for i in s]), sum([ord(i) for i in t])
         return chr(sum([ord(i) for i in t])-sum([ord(i) for i in s])) 

class Solution:
     def findTheDifference(self, s, t):
         """
         :type s: str
         :type t: str
         :rtype: str
         """
         s_dict = {}
         for letter in s:
             if letter not in s_dict:
                 s_dict[letter] = 1
             else:
                 s_dict[letter] += 1
         
         t_dict = {}
         for letter in t:
             if letter not in t_dict:
                 t_dict[letter] = 1
             else:
                 t_dict[letter] += 1
                 
         result = ''
         for letter in t:
             if letter not in s_dict:
                 result = letter
             elif t_dict[letter] > s_dict[letter]:
                 result = letter
         return result
                 
             


class Solution:
     def findTheDifference(self, s, t):
         """
         :type s: str
         :type t: str
         :rtype: str
         """
         ss = sorted(s)
         st = sorted(t)
         i = 0 
         j = 0
         while i <= len(ss) - 1:
             if ss[i] == st[j]:
                 i += 1
                 j += 1
             else: return st[j]
         return st[j]

class Solution:
     def findTheDifference(self, s, t):
         """
         :type s: str
         :type t: str
         :rtype: str
         """
         return [i for i in t if i not in s or s.count(i)!=t.count(i)][0]
     # one more letter not more than one letter and rtype=return type --string


class Solution:
     def findTheDifference(self, s, t):
         for i in t:
             if not i in s or t.count(i) != s.count(i):
                 return i


class Solution:
     def findTheDifference(self, s, t):
         """
         :type s: str
         :type t: str
         :rtype: str
         """
         for i in set(t):
             if i not in set(s) or t.count(i)>s.count(i):
                 return i

class Solution:
     def findTheDifference(self, s, t):
         """
         :type s: str
         :type t: str
         :rtype: str
         """
         s_map = {}
         for char in s:
             if char in s_map:
                 s_map[char] += 1
             else:
                 s_map[char] = 1
         t_map = {}
         for char in t:
             if char in t_map:
                 t_map[char] += 1
             else:
                 t_map[char] = 1
         for char in t_map:
             if (char not in s_map) or (t_map[char] > s_map[char]):
                 return char

class Solution:
     def findTheDifference(self, s, t):
         """
         :type s: str
         :type t: str
         :rtype: str
         """
         a = list(s)
         b = list(t)
         for c in s:
             a.remove(c)
             b.remove(c)
         return b[0]

class Solution:
     def findTheDifference(self, s, t):
         """
         :type s: str
         :type t: str
         :rtype: str
         """
         S = [i for i in s]
         T = [i for i in t]
         for i in S:
             T.remove(i)
         return T[0]