You are viewing a single comment's thread. Return to all comments →
Very Simple and Easy logic
static boolean isAnagram(String a, String b) { if(a.length()!=b.length()) { return false; }
int [] check = new int[26]; for(int i =0;i<a.length();i++) { check[a.toLowerCase().charAt(i)-'a']++; check[b.toLowerCase().charAt(i)-'a']--; } for(int i = 0;i<26;i++) { if(check[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 →
Very Simple and Easy logic
static boolean isAnagram(String a, String b) { if(a.length()!=b.length()) { return false; }