# Valid Anagram

{% tabs %}
{% tab title="Java" %}
```java
class Solution {
    public boolean isAnagram(String s, String t) {
        if (s == null && t == null) {
            return true;
        }
        if (s == null || t == null ||  s.length() != t.length()) {
            return false;
        }
        
        int[] counts = new int[26];
        int len = s.length();
        for (int i = 0; i < len; i++) {
            counts[s.charAt(i) - 'a']++;
            counts[t.charAt(i) - 'a']--;
        }
        
        for (int i = 0; i < counts.length; i++) {
            if (counts[i] != 0) {
                return false;
            }
        }
        return true;
    }
}

```
{% endtab %}
{% endtabs %}
