242. Valid Anagram(python)

  1. class Solution(object):  
  2.     def isAnagram(self, s, t):  
  3.         """ 
  4.         :type s: str 
  5.         :type t: str 
  6.         :rtype: bool 
  7.         """  
  8.         if len(s)!=len(t):  
  9.             return False  
  10.           
  11.         s1 = {}  
  12.         for i in list(set(s)):  
  13.             s1[i]=s.count(i)  
  14.         s2 = {}  
  15.         for j in list(set(t)):  
  16.             s2[j]=t.count(j)  
  17.               
  18.         return s1==s2  
  19.               

猜你喜欢

转载自blog.csdn.net/weixin_41362649/article/details/79975873