my python solution


  • 0
    H
    class Solution(object):
        def isAnagram(self, s, t):
            """
            :type s: str
            :type t: str
            :rtype: bool
            """
            s_list =[0]*26
            t_list = [0]*26
            if len(s) != len(t):
                return False
            for i in range(len(s)):
                s_list[ ord(s[i]) - 97 ] += 1
                t_list[ ord(t[i]) - 97 ] +=1
    
    
            # print(s_list)
            # print(t_list)
            if s_list == t_list:
                return True
            return False
    

Log in to reply
 

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