You are given two strings?s?and?t.
String?t?is generated by random shuffling string?s?and then add one more letter at a random position.
Return the letter that was added to?t.
class Solution {
? ? public char findTheDifference(String s, String t) {
? ? ? ? int n = 0;
? ? ? ? char[] sChar = s.toCharArray();
? ? ? ? char[] tChar = t.toCharArray();
? ? ? ? for (int i = 0;i < sChar.length;i++) {
? ? ? ? ? ? n ^= sChar[i];
? ? ? ? }
? ? ? ? for (int i = 0;i < tChar.length;i++) {
? ? ? ? ? ? n ^= tChar[i];
? ? ? ? }
? ? ? ? return (char)n;
? ? }
}