python leetcode 242. Valid Anagram

class Solution:
    def isAnagram(self, s, t):
        """
        :type s: str
        :type t: str
        :rtype: bool
        """
        dp1=[0]*26
        dp2=[0]*26
        if len(s) != len(t):
            return False 
        for c1 in s:
            dp1[ord(c1)-97]+=1 
        for c2 in t:
            dp2[ord(c2)-97]+=1 
        if dp1==dp2:
            return True 
        else:
            return False

猜你喜欢

转载自blog.csdn.net/Neekity/article/details/85104424