题解 | #字母异位词的长度#
字母异位词的长度
https://www.nowcoder.com/practice/59426f49136349b0901cc1b70447bf4b
int isCongruent(char* s, char* c ) {
// write code here
int hash[26] = {0};
int len_s = strlen(s);
int len_c = strlen(c);
if (len_s != len_c)
return -1;
for(int i = 0; i < len_c; i++)
{
hash[s[i] - 'a']++;
}
for(int i = 0; i < len_c; i++)
{
hash[c[i] - 'a']--;
}
for(int i = 0; i < 26; i++)
{
if(hash[i] != 0)
return -1;
}
return len_c;
}

快手公司福利 1244人发布