You are viewing a single comment's thread. Return to all comments →
static boolean isAnagram(String a, String b) {
int[] aChar=new int[27];
int[] bChar=new int[27];
int length,ac,bc;
if((length=a.length())!=b.length())
return false;
for(int i=0;i<length;i++){
if((ac=a.charAt(i))>92)
ac -= 32;
if((bc=b.charAt(i))>92)
bc -= 32;
aChar[ac-65]++;
bChar[bc-65]++;
}
for(int i=0;i<27;i++){
if(aChar[i]!=bChar[i]) return false; } return true; }
if(aChar[i]!=bChar[i]) return false; } return true;
Seems like cookies are disabled on this browser, please enable them to open this website
Java Anagrams
You are viewing a single comment's thread. Return to all comments →