Simple Python Solution


  • 0
    Y
    class Solution(object):
        def isIsomorphic(self, s, t):
            
            first = [-1]*256
            second = [-1]*256
            length = len(s)
            
            for i in range(len(s)):
                if first[ord(s[i])] != second[ord(t[i])]:
                    return False
                first[ord(s[i])] = i 
                second[ord(t[i])] = i
            return True

Log in to reply
 

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