389. 找不同

送分题

1
2
3
4
5
6
7
8
9
10
11
12
13
class Solution {
public:
char findTheDifference(string s, string t) {
map<char, int>count;
for(auto&&c:s){
count[c]++;
}
for(auto&&c:t){
count[c]--;
}
return find_if(count.begin(),count.end(),[&](auto it){return it.second!=0;})->first;
}
};