You are viewing a single comment's thread. Return to all comments →
JAVA MANUAL SORT AND COMPARISION--->
static boolean isAnagram(String A, String B) { // Complete the function
char sorteda[] = A.toUpperCase().toCharArray(); char sortedb[] = B.toUpperCase().toCharArray(); boolean flag = true; char temp ; if(A.length()==B.length()){ for(int x=0; x<A.length(); x++){ for(int y=x+1; y<A.length();y++){ if(sorteda[x]>sorteda[y]){ temp = sorteda[x]; sorteda[x] = sorteda[y]; sorteda[y] = temp; } if(sortedb[x]>sortedb[y]){ temp = sortedb[x]; sortedb[x] = sortedb[y]; sortedb[y] = temp; } } } for(int i=0; i<A.length(); i++){ //System.out.println(sorteda[i] + " " + sortedb[i]); if(sorteda[i]!=sortedb[i]){ flag = false; } } } else flag = false; return flag; }
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 →
JAVA MANUAL SORT AND COMPARISION--->
static boolean isAnagram(String A, String B) { // Complete the function