You are viewing a single comment's thread. Return to all comments →
I think it's the one of the most efficient way to solve this problem)
static boolean isAnagram(String a, String b) { a = a.toUpperCase(); b = b.toUpperCase(); if(a.length() != b.length()) { return false; } int[] array = new int[256]; for(int i = 0; i < a.length();i++) { array[a.charAt(i)]++; array[b.charAt(i)]--; } for(int i : array){ if(i != 0){ 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 →
I think it's the one of the most efficient way to solve this problem)