leetcode-easy-string-242. Valid Anagram

mycode   71.97%

class Solution(object):
    def isAnagram(self, s, t):
        """
        :type s: str
        :type t: str
        :rtype: bool
        """
        s = sorted(s)
        t = sorted(t)
        return  s == t

参考

class Solution(object):
    def isAnagram(self, s, t):
        """
        :type s: str
        :type t: str
        :rtype: bool
        """
        return all([s.count(c) == t.count(c) for c in string.ascii_lowercase])

用法

原文地址:https://www.cnblogs.com/rosyYY/p/10996258.html