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

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_22795513/article/details/80655684
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

猜你喜欢

转载自blog.csdn.net/qq_22795513/article/details/80655684