class Solution { public: bool isAnagram(string s, string t) { vector<int> ms(26,0),mt(26,0); for(auto& str:s) ++ms[str-'a']; for(auto& str:t) ++mt[str-'a']; for(int i=0;i<26;++i) { if(ms[i]!=mt[i]) return false; } return true; } };
2024-03-22 23:44:58
class Solution { public: bool isAnagram(string s, string t) { vector<int> ms(26,0),mt(26,0); for(auto& str:s) ++ms[str-'a']; for(auto& str:t) ++mt[str-'a']; for(int i=0;i<26;++i) { if(ms[i]!=mt[i]) return false; } return true; } };