Java solution-7ms


  • 0
    J

    '''
    public class Solution {
    public char findTheDifference(String s, String t) {

        int l = s.length() + t.length();
        int[] a = new int[l];
        int result = 0;
        
        s = s.concat(t);
        
        for (int i = 0; i < l; i++){
            
            char character = s.charAt(i);
            int ascii = (int) character;
            a[i] = ascii;
        }
        
        for (int j = 0; j < l; j++)
        {
            result ^= a[j];
        }
        
        char differenceChar = (char)result;
        return differenceChar;
    }
    

    }
    ‘’‘


Log in to reply
 

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