题目链接:https://leetcode.com/problems/valid-anagram
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.
Follow up:
What if the inputs contain unicode characters? How would you adapt your solution to such case?
class Solution {
public:
bool isAnagram(string s, string t) {
int a=true;
int sl=s.size();
int tl=t.size();
vector<int> flag(sl,0);
if(sl!=tl)
{
a=false;
}
else
{
sort(s.begin(),s.end());
sort(t.begin(),t.end());
if(s==t)
a=true;
else
a=false;
}
return a;
}
};