❤leetcode,python2❤有效的字母异位词

79 阅读1分钟
class Solution(object):
    def isAnagram(self, s, t):
        """
        :type s: str
        :type t: str
        :rtype: bool
        """

        if len(s) != len(t):
            return False
        while s:
            tmp = s[0]
            s=s.replace(tmp,'')
            t=t.replace(tmp,'')
            if len(s)!=len(t):
                return False
        return True