9. leetcode 389. Find the Difference
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.
思路:两个字符串中只有一个字符只出现了一次,所以等价于那个在一个数组中找出只出现一次的那个数的问题。利用异或操作。C++中可以用”[]”运算符索引string对象对应位置的字符。