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.
只要考虑小写字母。
public class Solution {
public boolean isAnagram(String s, String t) {
if(s.length()!=t.length())
return false;
int len = s.length();
int[] ss = new int[26];
int[] tt = new int[26];
for(int i=0;i<len;i++){
ss[s.charAt(i)-'a']++;
tt[t.charAt(i)-'a']++;
}
for(int i=0;i<26;i++){
if(ss[i]!=tt[i])
return false;
}
return true;
}
}