Is this problem mean that s consist of the upside down of some substr from t


  • 0
    G
    class Solution:
        # @param {string} s
        # @param {string} t
        # @return {boolean}
        def isAnagram(self, s, t):
            if len(s)!=len(t):
                return False
            d={}
            sum = 0
            for i in xrange(len(s)):
                ch = s[i]
                start = 0
                try:
                    start = d[ch]
                except:
                    pass
                ind = t.find(ch,start)
                if ind == -1:
                    return False
                d[ch] = ind + 1
                sum = sum + (ind-i)
            if sum==0:
                return True
            return False

  • 0
    G

    "abcd123efg" and "dcba123gfe" is True

    "abcd123fge" and "dcba123gfe" is False


Log in to reply
 

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