Advertisement
Guest User

Untitled

a guest
Oct 17th, 2019
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. class Solution(object):
  2. def findTheDifference(self, s, t):
  3. """
  4. :type s: str
  5. :type t: str
  6. :rtype: str
  7. """
  8. # O(n) – ops complexity
  9. # O(S) – (S = amount of chars) memory complexity
  10. cc = {}
  11. ct = {}
  12. for c in s:
  13. cc[c] = cc.get(c, 0) + 1
  14. for c in t:
  15. ct[c] = ct.get(c, 0) + 1
  16. for k, v in ct.items():
  17. if cc.get(k, -1) != v:
  18. return k
  19. return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement