You are viewing a single comment's thread. Return to all comments →
static boolean isAnagram(String a, String b) {
if (a.length() != b.length()) return false; a = a.toLowerCase(); b = b.toLowerCase(); String newB = ""; for (int i=0; i<a.length(); i++) { String check = String.valueOf(a.charAt(i)); if (b.contains(check)) { newB += a.charAt(i); b = b.replaceFirst(check, ""); }else { return false; } } return a.contains(newB) && b.isEmpty(); }
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 →
static boolean isAnagram(String a, String b) {