class Solution {
public boolean isAnagram(String s, String t) {
if (s.length() != t.length()) {
return false;
}
int[] counter = new int[128];
for (int i = 0; i < s.length(); i++) {
counter[s.charAt(i)]++;
counter[t.charAt(i)]--;
}
for (char c = 'a'; c <= 'z'; c++) {
if (counter[c] != 0) {
return false;
}
}
return true;
}
}
11-17
04-22
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交