242. 有效的字母异位词
https://leetcode-cn.com/problems/valid-anagram/
//时间复杂度 O(n)
//空间复杂度 O(1)
#define N 26
bool isAnagram(char * s, char * t){
int flag[N] = {0}; //额外恒定辅助空间
int slen = strlen(s), tlen = strlen(t);
if (slen != tlen) {
return false;
}
for (int i = 0; i < slen; i++) {
flag[s[i]-'a']++;
flag[t[i]-'a']--;
}
for (int i = 0; i < N; i++) {
if (flag[i] != 0) {
return false;
}
}
return true;
}