hacker rank java 18th problem(java anagrams ) solution
18. JAVA Anagrams
//pre written
static boolean isAnagram(String a, String b) {
a=a.toLowerCase();
b=b.toLowerCase();
char[] c=a.toCharArray();
char[] d= b.toCharArray();
java.util.Arrays.sort(c);
java.util.Arrays.sort(d);
String e=new String(c);
String f= new String(d);
if(e.compareTo(f)==0){
return true;
}
else{
return false;
}
}
Comments