Python solution: set() and count()


  • 0
    D
    class Solution(object):
        def isAnagram(self, s, t):
            """
            :type s: str
            :type t: str
            :rtype: bool
            """
            for letter in set(s+t):
                if s.count(letter) != t.count(letter):
                    return False
            return True
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.