fork download
  1. class Solution(object):
  2. def isAnagram(self, s, t):
  3. """
  4. :type s: str
  5. :type t: str
  6. :rtype: bool
  7. """
  8.  
  9. if len(s) != len(t):
  10. return False
  11. s_map = {}
  12. t_map = {}
  13.  
  14. for i in s:
  15. s_map[i] = s_map.get(i,0)+1
  16.  
  17. for j in t:
  18. t_map[j] = t_map.get(j,0)+1
  19.  
  20. for i in s_map:
  21. if i not in t_map or s_map[i] != t_map[i]:
  22. return False
  23. return True
  24.  
  25.  
Success #stdin #stdout 0.07s 14064KB
stdin
Standard input is empty
stdout
Standard output is empty