Given two strings s and t which consist of only lowercase letters.
String t is generated by random shuffling string s and then add one more letter at a random position.
Find the letter that was added in t.
Example:
Input: s = "abcd" t = "abcde" Output: e Explanation: 'e' is the letter that was added.
127/150
思路:A^0=A, 水一道题睡觉。明天Career fair :)
public class Solution { public char findTheDifference(String s, String t) { int len=s.length(),len2=t.length(); char res=t.charAt(len2-1); for(int i=0;i<len;i++){ res^=s.charAt(i); res^=t.charAt(i); } return res; } }