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; byte[] aBytes = a.toLowerCase().getBytes(); byte[] bBytes = b.toLowerCase().getBytes(); byte xor = 0; for( int i = 0; i < aBytes.length; i++ ) { xor ^= aBytes[i] ^ bBytes[i]; } return xor == 0; }
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 →