One Line java and python solution


  • 1
    F

    For java:

    public char findTheDifference(String s, String t) {
            return (char) (s + t).chars().reduce(0, (x, y) -> x ^ y);
        }
    

    For python:

    from operator import xor
    class Solution(object):
        def findTheDifference(self, s, t):
            return chr(reduce(xor, map(ord, s + t)))
    

Log in to reply
 

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