My Python submission. Better than up to 98%.


  • 2
    Z
    class Solution(object):
    def isAnagram(self, s, t):
        """
        :type s: str
        :type t: str
        :rtype: bool
        """
        alpha = [chr(ord('a')+i) for i in range(26)]
        countS = [s.count(char) for char in alpha]
        countT = [t.count(char) for char in alpha]
        for (x,y) in zip(countS,countT):
            if x != y:
                return False
        return True

Log in to reply
 

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