Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Solution(object):
- def findTheDifference(self, s, t):
- """
- :type s: str
- :type t: str
- :rtype: str
- """
- # O(n) – ops complexity
- # O(S) – (S = amount of chars) memory complexity
- cc = {}
- ct = {}
- for c in s:
- cc[c] = cc.get(c, 0) + 1
- for c in t:
- ct[c] = ct.get(c, 0) + 1
- for k, v in ct.items():
- if cc.get(k, -1) != v:
- return k
- return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement