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.
class Solution {
public:
bool isAnagram(string s, string t) {
int slength = s.size();
int tlength = t.size();
if (slength != tlength )//长度不相等,则一定为假
return false;
sort(s.begin(),s.end());//如果长度等,则把两个字符串排序,如果两个字符串的字母相同,则返回真,否则返回假
sort(t.begin(),t.end());
if (s == t)
return true;
else return false;
}
};