You are viewing a single comment's thread. Return to all comments →
Do vote if you like the solution.
static boolean isAnagram(String a, String b) { int[] charCount=new int[26]; for(char ch:a.toCharArray()){ charCount[Character.toLowerCase(ch) - 'a']++; } for(char ch:b.toCharArray()){ charCount[Character.toLowerCase(ch)-'a']--; } for(int count:charCount){ if(count!=0) return false; } return true; }
Seems like cookies are disabled on this browser, please enable them to open this website
I agree to HackerRank's Terms of Service and Privacy Policy.
Java Anagrams
You are viewing a single comment's thread. Return to all comments →
Do vote if you like the solution.