其他分享
首页 > 其他分享> > 389. 找不同

389. 找不同

作者:互联网

 1 class Solution 
 2 {
 3 public:
 4     char findTheDifference(string s, string t) 
 5     {
 6         unordered_map<char,int> hash;
 7         for(auto a : s) hash[a] ++;
 8         for(auto a : t)
 9         {
10             if(hash.find(a) == hash.end()) return a;
11             else
12             {
13                 hash[a] --;
14                 if(hash[a] == 0) hash.erase(a);
15             }
16         }
17         return ' ';
18     }
19 };

 

标签:return,string,auto,char,erase,不同,389,hash
来源: https://www.cnblogs.com/yuhong1103/p/12788393.html