LeetCode 389 Find the Difference

LeetCode 389 Find the Difference Problem

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

    # def findTheDifference(self, s, t):
    #     res = 0
    #     for c in s + t:
    #         res ^= ord(c)
    #     return chr(res)
        
Download Find the Difference.py

List of all Find the Difference problems

Leetcode 389 Find the Difference problem solution in python3 with explanation. This is the best place to expand your knowledge and get prepared for your next interview.

Feedback is the most important part of any website.

If you have any query, suggestion or feedback, Please feel free to contact us.