JAVA solution using XOR


  • 0
    W
    public char findTheDifference(String s, String t) {
        
        char[] arrayComb = (s+t).toCharArray();
        int valueAscii=0;
        
        for(int i = 0; i<arrayComb.length;i++){
            valueAscii ^= (int)arrayComb[i];
        }
        return (char)valueAscii;
    }

Log in to reply
 

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