0242.cpp (362B)
1 class Solution { 2 public: 3 bool isAnagram(string s, string t) { 4 if (s.size() != t.size()) return false; 5 vector<int> um(26, 0); 6 for (char c : s) 7 um[c - 'a']++; 8 for (char c : t) 9 if (!um[c - 'a']) 10 return false; 11 else 12 um[c - 'a']--; 13 return true; 14 } 15 };