We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
int n = a.length();
boolean flag = (n==b.length())?true:false;
if (!flag) return flag;
StringBuffer sb = new StringBuffer(a.toLowerCase());
for(char c : b.toLowerCase().toCharArray()){
if(sb.lastIndexOf(String.valueOf(c))>=0)
sb.deleteCharAt(sb.lastIndexOf(String.valueOf(c)));
else
break;
}
return (sb.length()==0)?flag:false;
}
Cookie support is required to access HackerRank
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 →
//using StringBuffer
static boolean isAnagram(String a, String b) {