Simple Python O(n) Solution


  • 4
    D
    class Solution(object):
        def isAnagram(self, s, t):
            maps = {}
            mapt = {}
            for c in s:
                maps[c] = maps.get(c,0)+1
            for c in t:
                mapt[c] = mapt.get(c,0)+1
            return maps == mapt

  • 0
    D

    For who gives the down vote, if you can leave a comment on why, that can help me improving.


Log in to reply
 

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