解决思路
map
使用一个数组记录26个字母a出现的次数,对于s记录其中每个字母的数字。
然后对于t,对该数组中减去每个数组中的次数
最后判断,如果有不是0的数值,说明不是
public boolean isAnagram(String s, String t) {//记录每个字母出现的次数int[] alph = new int[26];//累加for(char c:s.toCharArray()){alph[c-'a']++;}//累减for(char c:t.toCharArray()){alph[c-'a']--;}//如果有不是0的,则不是for(int i=0;i<26;i++){if(alph[i]!=0)return false;}return true;}
