4-line python using XOR


  • 0
    K

    Magic XOR

    class Solution(object):
        def findTheDifference(self, s, t):      
            
            a=ord(t[0])        
            for i in s+t[1:]:
                a=a^ord(i)
            return chr(a)
    

Log in to reply
 

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