1. 程式人生 > >python leetcode 242. Valid Anagram

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