My python solution beat 100%


  • 0
    L
    class Solution(object):
        def isIsomorphic(self, s, t):
            """
            :type s: str
            :type t: str
            :rtype: bool
            """
            dic1 = self.cons(s)
            dic2 = self.cons(t)
            s1 = [dic1[x] for x in s]
            t1 = [dic2[x] for x in t]
            return True if s1 == t1 else False
    
        def cons(self , lst):
            redic = {}
            flag = 0
            for i, ele in enumerate(lst):
                if not ele in redic:
                    redic[ele] = flag
                    flag +=1
            return redic
    

  • 0
    L

    https://discuss.leetcode.com/topic/57482/beats-100
    I‘m sorry, the judge was recently upgraded and it's now faster.So,this can't be a correct result.


Log in to reply
 

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