leetcode 389 map iterator 的使用

时间:2016-09-29 21:10:18   收藏:0   阅读:168
 1 class Solution {
 2 public:
 3     char findTheDifference(string s, string t) {
 4         map<char,int>Map_Temp;
 5         for(int i=0;i<s.size();i++)
 6         Map_Temp[s[i]-a]++;
 7         for(int i=0;i<t.size();i++)
 8         Map_Temp[t[i]-a]--;
 9         map<char,int>::iterator iter;
10         for(iter=Map_Temp.begin();iter!=Map_Temp.end();iter++)
11         if(iter->second)
12         return char(iter->first+a);
13         return 0;
14     }
15 };

 

原文:http://www.cnblogs.com/thefirstfeeling/p/5920901.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!