Answers for "anagrams java solution"

0

Anagram Solution java

public boolean isAnagram(String s, String t) {
    if (s.length() != t.length()) {
        return false;
    }
    int[] counter = new int[26];
    for (int i = 0; i < s.length(); i++) {
        counter[s.charAt(i) - 'a']++;
        counter[t.charAt(i) - 'a']--;
    }
    for (int count : counter) {
        if (count != 0) {
            return false;
        }
    }
    return true;
}
Posted by: Guest on May-14-2021

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language