class Solution {
public char findTheDifference(String s, String t) {
if (s == null) {
return t.charAt(0);
}
// 一阿斯特玛作为数组的下标 存储每个字符出现的次数
int [] hashTable = new int [26];
int sizeS = s.length();
int sizeT =t.length();
// 遍历数组 这里要小于t的长度 因为t的长度是最长的
for (int i=0;i<sizeT;i++) {
// 如果字符属于s的字符 就将字符次数放到数组中
// s中字符出现的一次 减一 t中字符出现一次加一 最后遍历数组 如果数组的值为0 代表不是
// 我们想找的如果值为1 就是我们想找的 返回就可以
if (i < sizeS) {
hashTable[s.charAt(i)-'a']--;
}
hashTable[t.charAt(i) -'a']++;
}
// 最后返回我们需要返回的次数
for (int j=0;j<hashTable.length;j++) {
if (hashTable[j] == 1) {
return (char)(j+'a');
}
}
// 这里的b是随便写的 主要是为了程序的健壮性
return 'b';
}
}