题目
LeetCode - 242. Valid Anagram
题目链接
https://leetcode.com/problems/valid-anagram/
参考博客
解题思路
解题源码
class Solution {
public:
bool isAnagram(string s, string t) {
int a[26];
for (int i = 0; i < 26; i++) a[i] = 0;
for(auto it : s){
a[it - 'a']++;
}
for(auto it : t){
a[it - 'a']--;
}
for (int i = 0; i < 26; i++){
if (a[i]) return false;
}
return true;
}
};