where is the bug in this code?

  • 0

    Re: Python different solutions (dictionary.)

    I write a code like this, but I can not pass the last test with extremely long str. It is expected False, my code return True. anyone know where the bug is?

    class Solution(object):
        def isIsomorphic(self, s, t):
            if len(s) != len(t):
                return False
            count = len(s) - 1
            for i in range(count):
                same_s = s[i] == s[i+1]
                same_t = t[i] == t[i+1]
                if same_s != same_t:
                    return False
            return True

Log in to reply

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