# 242. Valid Anagram

Given two strings _s_ and _t_ , write a function to determine if _t_ is an anagram of _s_.

**Example 1:**

```
Input: s = "anagram", t = "nagaram"
Output: true
```

**Example 2:**

```
Input: s = "rat", t = "car"
Output: false
```

**Note:**\
You may assume the string contains only lowercase alphabets.

**Follow up:**\
What if the inputs contain unicode characters? How would you adapt your solution to such case?

```cpp
bool isAnagram(string s, string t) { // time: O(n); space: O(1)
    int m = s.length(), n = t.length();
    if (m != n) return false;
    vector<int> count(26, 0);
    for (int i = 0; i < m; ++i) {
        ++count[s[i] - 'a'];
        --count[t[i] - 'a'];
    }
    for (int num : count) {
        if (num) return false;
    }
    return true;
}
```

```cpp
// Follow-up: extend to unicode instead of only lowervase alphabets
bool isAnagram(string s, string t) { // time: O(n); space: O(1)
    int m = s.length(), n = t.length();
    if (m != n) return false;
    vector<int> count(128, 0);
    for (int i = 0; i < m; ++i) {
        ++count[s[i]];
        --count[t[i]];
    }
    for (int num : count) {
        if (num) return false;
    }
    return true;
}
```
