您的位置:首页 > 编程语言

两个字符串是否是变位词(直接lintcode敲代码,一次通过,噢耶!)

2016-07-26 18:55 579 查看
class Solution {
public:
/**
* @param s: The first string
* @param b: The second string
* @return true or false
*/
bool anagram(string s, string t) {
// write your code here
map<char,int> m1,m2;
for(auto c:s){
m1[c]++;
}
for(auto b:t){
m2[b]++;
}
for(auto a:m1){
if(m1[a.first]!=m2[a.first])
return false;
}
return true;
}
};
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: