Given two strings s and t, write a function to determine if t is an anagram of s.
For example,
s = "anagram", t = "nagaram", return true.
s = "rat", t = "car", return false.
Note:
You may assume the string contains only lowercase alphabets.
1 class Solution { 2 public: 3 bool isAnagram(string s, string t) { 4 unordered_map<char, int> ms; 5 unordered_map<char, int> mt; 6 int slen = s.size(); 7 int tlen = t.size(); 8 for (int i = 0; i < slen; i++) 9 { 10 ms[s[i]]++; 11 } 12 for (int i = 0; i < tlen; i++) 13 { 14 mt[t[i]]++; 15 } 16 if (ms == mt) 17 return true; 18 else 19 return false; 20 } 21 };