Python 2 lines O(n) solution using Counter


  • 0
    C
    class Solution(object):
        def isAnagram(self, s, t):
            from collections import Counter
            return len(s) == len(t) and not(Counter(s) - Counter(t))
    

Log in to reply
 

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