easy JAVA code...


  • 1
    D
    public class Solution {
        public char findTheDifference(String s, String t) {
            int c=t.charAt(0);
            for (int i=0; i<s.length(); i++) c=c^s.charAt(i);
            for (int i=1; i<t.length(); i++) c=c^t.charAt(i);
            return (char)c;
        }
    }
    

Log in to reply
 

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