Accepted Python Solution (1 liner)

  • 0
    import collections
    from collections import Counter
    def isAnagram(self, s, t):
          return Counter(s) == Counter(t)

    Counter constructors accept any form of iterable and return a dictionary with the count per character.

Log in to reply

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