one pass python solution


  • 1
    M
    class Solution(object):
        def findTheDifference(self, s, t):
            """
            :type s: str
            :type t: str
            :rtype: str
            """
            k = 0
            for i in range(len(s)):
                k -= ord(s[i])
                k += ord(t[i])
                
            k+=ord(t[-1])
            return chr(k)
    

Log in to reply
 

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