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])

用法

leetcode-easy-string-242. Valid Anagram

 

相关文章:

  • 2022-01-21
  • 2022-02-12
  • 2021-09-28
  • 2021-10-12
  • 2021-08-30
  • 2022-12-23
猜你喜欢
  • 2021-12-02
  • 2021-05-07
  • 2021-04-11
  • 2021-06-20
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案