题目
leetcode 链接:https://leetcode-cn.com/problems/valid-anagram/
解法
class Solution {
public boolean isAnagram(String s, String t) {
if (s.length() != t.length()) {
return false;
}
int[] tmp = new int[26];
char[] str = s.toCharArray();
for (char c : str) {
tmp[c - 97]++;
}
str = t.toCharArray();
for (char c : str) {
if (tmp[c - 97]-- < 1) {
return false;
}
}
return true;
}
}