class Solution {
public:
bool isAnagram(string s, string t) {
unordered_map<char,int> m;
for(auto i:s) m[i]++;
for(auto i:t) m[i]--;
for(auto i:m) {
if(i.second!=0) return false;
}
return true;
}
};
Leetcode242(力扣242):有效的字母异位词
最新推荐文章于 2024-06-21 11:16:10 发布